Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery multiple check box enable text field
    primarykey
    data
    text
    <p>from previous questions <a href="https://stackoverflow.com/questions/18554413/checkbox-enable-onload-to-display-other-elements">checkbox enable onload to display other elements</a></p> <p>ok, since none of these worked, im going to have to just display my actual code instead of an example. i was just trying to use an example then apply it to my problem, but none of your solutions worked with my situation. </p> <p>so here it is. $stuff comes from mysql and is either enabled or disabled, the check mark needs to be checked if the $stuff is 'enabled' or unchecked if 'disabled'.</p> <p>HTML</p> <pre><code>&lt;tr&gt; &lt;td&gt;blah&lt;/td&gt; &lt;td&gt; &lt;?php if ($stuff1 == 'enabled'){ echo "&lt;input type='checkbox' name='a1' id='checker' checked=checked&gt;"; } else { echo "&lt;input type='checkbox' name='a1' id='checker'&gt;"; } ?&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' name='a1_1' size='25' maxlength='5' value='&lt;?php echo $a1_1 ?&gt;'&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' name='a2_2' size='25' maxlength='5' value='&lt;?php echo $a2_2 ?&gt;'&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' name='a3_3' size='25' maxlength='5' value='&lt;?php echo $a3_3 ?&gt;'&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;?php if ($stuff2 == 'enabled'){ echo "&lt;input type='checkbox' name='b1' id='checker2' checked=checked&gt;"; } else { echo "&lt;input type='checkbox' name='b1' id='checker2'&gt;"; } ?&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" type="text" size="25" maxlength='5' value='&lt;?php echo $b1_1 ?&gt;'&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" type="text" size="25" maxlength='5' value='&lt;?php echo $b2_2 ?&gt;'&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" type="text" size="25" maxlength='5' value='&lt;?php echo $b3_3 ?&gt;'&gt;&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>This is was my previous jquery code</p> <pre><code>$(document).ready(function() { toggleInputs($('#checker')); $('#checker').click(function () { toggleInputs($(this)); }); }); function toggleInputs(element) { if (element.prop('checked')) { $('#tb1').prop('disabled', false); $('#tb2').prop('disabled', false); $('#tb3').prop('disabled', false); } else { $('#tb1').prop('disabled', true); $('#tb2').prop('disabled', true); $('#tb3').prop('disabled', true); } } </code></pre> <p>if tested you can see that the top check mark only functions with the 2nd input on the form.</p> <p>My situation: in this form, you have 2 values $stuff1 and $stuff2, the options they have are either enabled or disabled, they will never be consistent. when php test's if the value is enabled, the value checks the check mark, and enables the 3 box fields. if it's disabled, the check mark is unchecked and the 3 boxes display is as grayed out. The user can now check (to enable) the checkmark and display the 3 text fields, or uncheck (to disable) the check mark and gray out the 3 fields.</p> <p>this will eventually goto a POST at the bottom and send all the values of the fields and the check marks back to mysql.</p> <p>I was able to do this flawless here <a href="http://jsfiddle.net/MVGys/9/" rel="nofollow noreferrer">http://jsfiddle.net/MVGys/9/</a> with only 1 checkmark, not multiple checkmarks on the same form.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    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