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?
You can do it using a simple javascript. Here onChange event will be invoked whenever user changes the value in the select box and this. form. submit() method will submit the form.
Input value attribute The value attribute can be used to change the text of the form submit button. Use value attribute within <input> of type="submit" to rename the button.
To clear an input field after submitting:Add a click event listener to a button. When the button is clicked, set the input field's value to an empty string. Setting the field's value to an empty string resets the input.
You 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();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With