Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><em>Updated Answer</em></p> <p>Given what you seem to be trying to accomplish I think using classes and data attributes might serve as the easiest and most flexible solution. </p> <p><strong>OP's HTML (Modified)</strong></p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt;blah&lt;/td&gt; &lt;td&gt; &lt;input type='checkbox' name='a1' class="group_ctrl" data-group="group_a" id='checker'&gt; &lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;div align="right"&gt;a1:&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;input id="tb1" type='text' class="group_a" name='a1_1' size='25' maxlength='5' value='a1_1'&gt; &lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;div align="right"&gt;a2:&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;input id="tb2" type='text' class="group_a" name='a2_2' size='25' maxlength='5' value='a2_2'&gt; &lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;div align="right"&gt;a3:&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;input id="tb3" type='text' class="group_a" name='a3_3' size='25' maxlength='5' value='a3_3'&gt; &lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;div align="center"&gt;Activate Something Else&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;input type='checkbox' name='b1' class="group_ctrl" data-group="group_b" id='checker2' checked=checked&gt; &lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;div align="right"&gt;b1:&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;input id="tb4" name="b1_1" class="group_b" type="text" size="25" maxlength='5' value='b1_1'&gt; &lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;div align="right"&gt;b2:&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;input id="tb5" name="b2_2" class="group_b" type="text" size="25" maxlength='5' value='b2_2'&gt; &lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;div align="right"&gt;b3:&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;input id="tb6" name="b3_3" class="group_b" type="text" size="25" maxlength='5' value='b3_3'&gt; &lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p><strong>JQuery</strong></p> <pre><code>$(document).ready(function() { $('.group_ctrl').change(function () { // gets data-group value and uses it in the outer selector // to select the inputs it controls and sets their disabled // property to the negated value of it's checked property $("." + $(this).data("group")).prop('disabled', !this.checked); }).change(); }); </code></pre> <p><a href="http://jsfiddle.net/X5rRj/8/" rel="nofollow">fiddle</a></p> <p>I have given every input you want to disable/enable a class. E.g. group_[a|b] Then I gave the check-box controls a class group_ctrl and a data attribute named group (data-group) with the corresponding group class it is responsible for controlling as the value. You can duplicate this pattern as many times as needed. E.g. group_c, group_d, group_e... etc. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload