Hello everybody.
Condition.
There is a first block, it has three checkboxes:
<input id="enableOne" type="checkbox" />1 разряд<br /> <input id="enableTwo" type="checkbox" />2 разряд<br /> <input id="enableNo" type="checkbox" />Нет разряда<br /> There is a second block, there are several disabled checkboxes in it:
<input class="check" id="1" type="checkbox" />1<br /> <input class="check" id="2" type="checkbox" />2<br /> <input class="check" id="3" type="checkbox" />3<br /> <input class="check" id="4" type="checkbox" />4<br /> <input class="check" id="5" type="checkbox" />5<br /> Task.
It is necessary that when selecting one of the checkboxes in the first block, the checkboxes tied to it in the second block are activated (the option of ticking it on). For example, when selecting “1 digit” 1-5 checkboxes are activated, “2 digit” - 1,2 and 3 checkboxes, etc. Those. A person, having chosen his rank, can mark only checkboxes tied to this rank. Therefore, it is necessary to bind certain checkboxes in the second block by "id" to each checkbox from the first block.
If a person removes a tick in the first block, then the selected checkboxes in the second block should be cleared and deactivated.
On the Internet, I found a script that allows ticking one checkbox to include others. Code below:
<input id="enableAll" type="checkbox" />000 <input class="check" type="checkbox" />1 <input class="check" type="checkbox" />2 <input class="check" type="checkbox" />3 $(function(){ $("input.check").attr("disabled","disabled"); $("input#enableAll").click( function(){ if($(this)[0].checked==false) $("input.check").attr("disabled","disabled") else $("input.check").removeAttr("disabled") } ) } ) How can I convert it to my task? For JS I do not understand. Thank you in advance for your help.