I have worked out how on clicking the radio button how to check a checkbox on my page, however this selects on the ID of the checkbox. The checkboxes on my page a dynamically generated with an id number on the end.
<input type="checkbox" certificate="false" id="gridcb0" siteid="23445" value="72278" class="custom selector">
Option One<br />
<input type="checkbox" certificate="false" id="gridcb1" siteid="23445" value="72278" class="custom selector">
Option Two<br />
<input type="checkbox" certificate="false" id="gridcb2" siteid="23445" value="72278" class="custom selector">
Option Three<br />
<input type="checkbox" certificate="false" id="gridcb3" siteid="23445" value="72278" class="custom selector">
Option Four<br />
<input type="checkbox" certificate="false" id="gridcb4" siteid="23445" value="72278" class="custom selector">
Option Five<br />
<input type="radio" id="op5" value="1" name="options2" class="custom">
Select All
As you can see the IDs are gridcb0
to gridcb5
however the number on the end could go on in the hundreds.
Here my JS
jQuery('#op5').click(function(){
jQuery('#gridcb0').attr('checked', true);
});
At the moment this will only select the top checkbox, how can change this JS so I cycle through and check all the required checkboxes?
Aucun commentaire:
Enregistrer un commentaire