CheckBoxFor renders a hidden field with the same name (and for good reason)
I need to enable/disable some other INPUT fields based on the value of the CheckBox when the page loads. However, I can’t get the JQuery selector right. My function ends up firing twice because the selector is getting both the CheckBox and the Hidden input fields.
This is what I have tried and neither work:
$('input[name$="Selected",type=checkbox]').each(function (){
alert('here ' + this.name);
EnableOrderItemDropDowns(this);
});
$('input[name$="Selected"],:checkbox').each(function (){
alert('here ' + this.name);
EnableOrderItemDropDowns(this);
});
Neither of these approaches work. The latter approach still doesn’t filter to just the CheckBox inputs, so the call to EnableOrderItemDropDowns still fires twice.
1 Answer