Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think some error comes from these lines:</p> <pre><code>var array = $.parseJSON(response.new_list); </code></pre> <p>returns a well formatted Javascript object but when you are comparing with</p> <pre><code>if($('#checkKeywords :input') == array){...} </code></pre> <p>You're comparing a set of Javascript objects with well formatted JSON parsed JS objects which are not quite compatible with the value returned from <code>$('#checkKeywords :input') == array</code>.</p> <blockquote> <p>If both operands are objects, they're compared as objects, and the equality test is true only if both refer the same object. <a href="https://developer.mozilla.org/en/JavaScript/Reference/Operators/Comparison_Operators" rel="nofollow">MDN Docs</a></p> </blockquote> <hr> <p>I would suggest to make the two objects comparable using some modification which will take the two objects and process them to return <code>true</code> or <code>false</code> according to whether the are equal.</p> <p><strong>Update</strong>:</p> <p>In your <strong>HTML code</strong></p> <pre><code>&lt;td&gt; &lt;input type="checkbox" id="validate" name="cb" value="{{keyword.keyword_name}}" /&gt;{{keyword.keyword_name}} &lt;/td&gt; </code></pre> <p>From your <strong>JS</strong></p> <pre><code>... $.each(array, function(i, item) { html += "&lt;li&gt;" + item + "&lt;/li&gt;"; theinputs = $('#checkKeywords :input') $.each(theinputs, function(i, checkbox) { if ($(checkbox).val() == item) { $(checkbox).prop('disabled', true); /* thanx charlietfl */ } }); }); $('#keywords').append(html); ... </code></pre>
 

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