I am trying to dynamically change a text input's value between 1 and 0 if a certain checkbox is checked or unchecked.
Here is my code:
jQuery(function () {
jQuery('#input_7_37_1').click(function() {
if (jQuery(this).is(":checked")) {
jQuery("#input_7_55").val( "0" );
} else {
jQuery("#input_7_55").val( "1" );
}
});
});
#input_7_37_1 is the ID of the checkbox whose value (checked or unchecked) that I'm interested in. #input_7_55 is the ID of the text input field I want to change the value to either 1 or 0. The default value of #input_7_55 is 1.
When I check #input_7_37_1, the value of #input_7_55 remains 1, when I am trying to get it to change to 0.
Aucun commentaire:
Enregistrer un commentaire