Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to change class property inside a checkbox
    primarykey
    data
    text
    <p>if user inputs a value in the input field the class value on the checkbox will change automatically</p> <p>input field:</p> <pre><code> &lt;input style="width:25px; margin-left:5px;" type="text" name="qtyA" id="qtyA" /&gt; </code></pre> <p>checkbox: </p> <pre><code>&lt;input id="INsrv1" name="INopt" type="checkbox" value="1" /&gt;1&lt;br&gt; &lt;input id="INsrv2" name="INopt" type="checkbox" value="2" /&gt;2&lt;br&gt; &lt;input id="INsrv3" name="INopt" type="checkbox" value="3" /&gt;3&lt;br&gt; &lt;input id="INsrv4" name="INopt" type="checkbox" value="4" /&gt;4&lt;br&gt; </code></pre> <p>javascript: </p> <pre><code>&lt;script&gt; $(document).ready(function() { $('#qtyA').on('change', function() { var max = $(this).val(); }); $("[name$='INopt']").prop('class','validate[minCheckbox[1],maxCheckbox[max]] checkbox text') }); &lt;/script&gt; </code></pre> <p>for ex:</p> <p>the user inputs 3 in input field "qtyA" </p> <p>value : 3</p> <p>the maxCheckbox[] value on the script will change along with it </p> <p>from maxCheckbox[1] to maxCheckbox[3]</p> <p>the actual code:</p> <pre><code> &lt;script&gt; $(document).ready(function() { $('#qtyA').on('change', function() { var max = $(this).val(); alert(max); }); $("#srv").on('change', function() { var max = $('#qtyA').val(); alert(max); var selVal = $(this).val(); if (selVal == 'Inbound') { // Inbound $('.Inbound').show(); $('.Outbound').hide(); $("[name$='OUTopt']").prop('class','') $("#OUTsrvOtr").prop('class','') $("[name$='INopt']").prop('class','validate[minCheckbox[1],maxCheckbox[max]] checkbox text') $('#valOUT').val(''); $('div#Outbound').find('span').prop('class',''); } else if (selVal == 'Outbound') { // Outbound $('.Inbound').hide(); $('.Outbound').show(); $("[name$='INopt']").prop('class','') $("#INsrvOtr").prop('class','') $("[name$='OUTopt']").prop('class','validate[minCheckbox[1],maxCheckbox[max]] checkbox text') $('#valIN').val(''); $('div#Inbound').find('span').prop('class',''); } else { $('.Inbound').hide(); $('.Outbound').hide(); $('#valOUT').val(''); $('#valIN').val(''); $("[name$='INopt']").prop('class','') $("#OUTsrvOtr").prop('class','') $('div#Inbound').find('span').prop('class',''); $("[name$='OUTopt']").prop('class','') $("#OUTsrvOtr").prop('class','') $('div#Outbound').find('span').prop('class',''); } }); }); &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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. 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