Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to "check" certain checkboxes only using Jquery?
    primarykey
    data
    text
    <p>I have a HTML form containing checkboxes in the form of .. </p> <pre><code>&lt;input type="checkbox" name="range[]" class="range_opts" id="range-1" value="1" /&gt; 1 &lt;br /&gt; &lt;input type="checkbox" name="range[]" class="range_opts" id="range-2" value="2" /&gt; 2 &lt;br /&gt; &lt;input type="checkbox" name="range[]" class="range_opts" id="range-3" value="3" /&gt; 3 &lt;br /&gt; ... ... &lt;input type="checkbox" name="range[]" class="range_opts" id="range-28" value="28" /&gt; 28&lt;br /&gt; &lt;input type="checkbox" name="range[]" class="range_opts" id="range-29" value="29" /&gt; 29&lt;br /&gt; &lt;input type="checkbox" name="range[]" class="range_opts" id="range-30" value="30" /&gt; 30&lt;br /&gt; </code></pre> <p>With this JS Code I Select all or Deselect all checkboxes </p> <pre><code>$('#select_all_ranges').click(function() { $('input[name="range[]"]').each(function() { this.checked = true; }); }); $('#deselect_all_ranges').click(function() { $('input[name="range[]"]').each(function() { this.checked = false; }); }); </code></pre> <p>But I need the functionality where user would be able to have certain checkboxes selected, depending upon the input </p> <pre><code> &lt;input type="text" name="from_range" id="frm_range" /&gt; &lt;input type="text" name="to_range" id="to_range" /&gt; &lt;img src="icon.png" id="range123" /&gt; </code></pre> <p>so if user inputs from 5 to 20 and clicks on icon it checks checkboxes from 5-20. </p> <p>Can you please help me some ideas how this can be achieved. I can alter markup to apply some classes/selecter ids etc if you suggest, if it would make it any easier. And I understand that this functionality is for users having javascript enabled browsers.</p> <p>Thanks.</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.
 

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