Hello, I have such select list in html:
<input type="checkbox" name="drive_style" value=1 checked />123<br />
<input type="checkbox" name="drive_style" value=2 />123<br />
<input type="checkbox" name="drive_style" value=3 checked /> 123<br />
<input type="checkbox" name="drive_style" value=4 />123<br />
<input type="checkbox" name="drive_style" value=5 checked />123<br />
I have to send values(1, 3, ...) of checked boxes to the php script (I'm using ajax with jquery) like an array. Something like: drive_style[index].
$.post('post_reply.php', {'drive_style' : $('drive_style')}, function(data){
alert(data);
});
In PHP script:
print_r($_POST['drive_style']);
[object Object]
upd: My new code:
<input type="checkbox" name="drive_style[]" value=1 checked />123<br />
<input type="checkbox" name="drive_style[]" value=2 />123<br />
<input type="checkbox" name="drive_style[]" value=3 checked />123<br />
<input type="checkbox" name="drive_style[]" value=4 />123<br />
<input type="checkbox" name="drive_style[]" value=5 checked />123<br />
$.post('post_reply.php', {'drive_style':$('input[name=drive_style]').serialize()}, function(data){
alert(data);
});
It alerts empty string.