I have a form with some checkboxes which go like this:
<input type="checkbox" id="id6" value="3" onclick="optionselect('day','3','id6','50')" />
Conditioned on another input I can have these checkboxes checked automatically but for some reason I can't trigger the "optionselect".
I've tried some of the following, but nothing works:
$("#id6").prop("checked", true).trigger("click");
$("#id6").prop("checked", true).triggerHandler("click");
$("#id6").prop("checked", true).click();
FYI, "optionselect" just does a bit of math in some other text inputs.
I think that problem is that you should use
onchange
event in this case, notclick
. Try this:and
Basically
.click()
effectively unchecks checkbox after you checked it withprop('checked', true)
.