I have a form with multiple input checkbox fields. I want to trigger form submit on change in any of the checkbox without submit button.
<form action="" method="get">
<input type="checkbox" name="p[]" value="1">
<input type="checkbox" name="p[]" value="2">
<input type="checkbox" name="p[]" value="3">
</form>
How it can be done with jQuery?
I have a form with multiple input checkbox fields. I want to trigger form submit on change in any of the checkbox without submit button.
<form action="" method="get">
<input type="checkbox" name="p[]" value="1">
<input type="checkbox" name="p[]" value="2">
<input type="checkbox" name="p[]" value="3">
</form>
How it can be done with jQuery?
Share Improve this question edited Aug 3, 2016 at 8:15 Rory McCrossan 338k41 gold badges320 silver badges351 bronze badges asked Aug 3, 2016 at 8:13 Anuj TBEAnuj TBE 9,79034 gold badges146 silver badges304 bronze badges1 Answer
Reset to default 16You could hook to the change()
event of the checkboxes, then fire a submit()
on the parent form
, like this:
$('form input').on('change', function() {
$(this).closest('form').submit();
});