$('form').serialize();
<label>Check what applies:</label>
Laptop Owner: <input type="checkbox" name="applicable" value="laptop owner" /> <br />
Samsung Tv Lover: <input type="checkbox" name="applicable" value="Samsumg tv lover" /> <br />
Animae Watcher: <input type="checkbox" name="applicable" value="Ani开发者_JAVA百科mae watcher" />
If I check "Laptop Owner" and "Animae Watcher" is only returns the latter, why? I need it to return both.
EDIT
I should say when I send the forms values to PHP it only returns the last checked checkbox, this is what my php looks like:
<?php
echo $_POST['applicable'].' says PHP';
?>
change name="applicable"
to name="applicable[]"
<?php
print_r( $_POST['applicable'] );
?>
When $('form').serialize()
is called it finds every input-textarea-select element inside the form tag and merge them with their name...
I am not sure how you have called .serialize() function so can't say anything because I have tested your code in my pc placing it inside a form element and it just work fine.
You better check JQuery documentation on this function: http://api.jquery.com/serialize/
精彩评论