So, I have this problem when I need to set a value for a checkbox depending on some variables.
The problem is that I came across the following HTML naming convention with which I will work:
<input id="jc_1" type="checkbox" name="jc[1]"> <input id="jc_2" type="checkbox" name="jc[2]"> <input id="jc_3" type="checkbox" name="jc[3]"> <input id="jc_4" type="checkbox" name="jc[4]">
To decide which input to select, I would usually do:
document.getElementsByName('jc')
Then skip all of them and decide which one to check, the problem is that I really do not know how to deal with this situation in these specific conditions.
I cannot use jQuery, and I cannot change my HTML markup.
Mandi source share