I have a simple checkbox, generated with:
<%= Html.CheckBox("myCB" )%>
How can I add an onChange handler to this that does a submit?
Add an onClick handler to the CheckBox that submits the form the CheckBox belongs to...quick, clickHandler codeless example:
<%= Html.CheckBox("myCB",
new { onClick = "$(this).parent('form:first').submit();" });
(example definitely not checked for accuracy)
If you have only one form, and are not using JQuery (you should be, by the way) try this:
<%= Html.CheckBox("myCB",
new { onClick = "document.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