Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery table id and disabled checkboxes
    primarykey
    data
    text
    <p>I've a question on using Jquery on a table.</p> <p>I don't know if I'm doing it the right way and hence I ended up asking my question here after much research.</p> <p>What I want is to compare the items in the variable array which holds the string converted response from JSON and if they match the list in the table, the checkbox would be disabled.</p> <p>Appreciate any inputs. :)</p> <p><strong>jQuery code</strong>:</p> <pre><code>function refreshKeywords(e) { e.preventDefault(); var refresh_form = jQuery(e.target); $.ajax({ url: refresh_form.attr('action'), type: refresh_form.attr('method'), data: refresh_form.serialize(), dataType: 'json', success: function(response) { var array = $.parseJSON(response.new_list); alert(array); var html = ''; $.each(array, function(i, item) { html += "&lt;li&gt;" + item + "&lt;/li&gt;"; if ($('#checkKeywords :input') == array) { $('#validate').attr('disabled', true); } }); $('#keywords').append(html); if ($('#checkKeywords :input') == array) { $('#validate').attr('disabled', true); } }, }); } </code></pre> <p>Below is my table HTML code:</p> <pre><code>&lt;table id="checkKeywords"&gt; &lt;tbody&gt; {% for keyword in keyword_list %} {% if forloop.counter|divisibleby:"3" %}&lt;tr&gt;{% endif %} &lt;td&gt; &lt;input type="checkbox" id= "validate" name="cb" value="keywords" /&gt; {{keyword.keyword_name}} &lt;/td&gt; {% if forloop.counter|add:"1"|divisibleby:"3" %}&lt;/tr&gt;{% endif %} {% endfor %} &lt;/tbody&gt; &lt;/table&gt; </code></pre>
    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. 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