jQuery submit form on checkbox press
I am trying to submit a form on 开发者_高级运维checking or unchecking a checkbox using jQuery and using the data value of that checkbox, can someone help me on how to do this?
The requirement of submitting the value of the box you just un-checked is the unusual bit here. One option is to stuff that value into a hidden field, which will be submitted. So:
<input name="checkbox_trigger" id="checkbox_trigger" value="" type="hidden" />
Then:
$('#yourcheckbox').click( function(e){
$('#checkbox_trigger').val( e.value ); // capture on check or uncheck
$(this).closest('form').submit();
});
If the name of the checkbox is also significant, you can easily follow this pattern to capture the field name as well.
i think you should try using .trigger
i think there is a trigger submit
$('#yourElement').live('click', function(){
$('#yourForm').trigger('submit');
})
精彩评论