Note that there are some explanatory texts on larger screens.

plurals
  1. POmake a returned JSON boolean value check a checkbox in JQuery
    text
    copied!<p>I'm trying to figure out what I'm doing wrong here. Using autocomplete I'm getting data that's being returned with JSON data ....</p> <h2>Here's the JSON data thats returning from the QUERY.</h2> <pre><code> [{"value":"Company Test 1 Manager Test 1 111-111-1111","Company_Name":"Company Test 1","Manager":"Manager Test 1","Phone":"111-111-1111","Contacted":"1"}, {"value":"Company Test 2 Manager Test 2 222-222-2222","Company_Name":"Company Test 2","Manager":"Manager Test 2","Phone":"222-222-2222","Contacted":"0"}, {"value":"Company Test 3 Manager Test 3 333-333-3333","Company_Name":"Company Test 3","Manager":"Manager Test 3","Phone":"333-333-3333","Contacted":"0"}, {"value":"Company Test 4 Manager Test 4 444-444-4444","Company_Name":"Company Test 4","Manager":"Manager Test 4","Phone":"444-444-4444","Contacted":"1"}, {"value":"Company Test 5 Manager Test 5 555-555-5555","Company_Name":"Company Test 5","Manager":"Manager Test 5","Phone":"555-555-5555","Contacted":"0"},] </code></pre> <h1>Now, here's my JQuery (using JQuery 1.6.2)</h1> <pre><code>&lt;script type="text/javascript"&gt; $(function() { $('#Company_Name').val(""); $('#Manager').val(""); $('#Phone').val(""); $('#Contacted').val(""); $("#autoSearch").autocomplete({ source: "UPDATE.test001QUERY.php", minLength: 2, select: function(event, ui) { $('#Company_Name').val(ui.item.Company_Name); $('#Manager').val(ui.item.Manager); $('#Phone').val(ui.item.Phone); if ('#Contacted' == [1]) { $('#Contected').prop('checked', true); } else { $('#Contected').prop('checked', false); } } }); }); &lt;/script&gt; </code></pre> <p>What did I do wrong? The autocomplete works fine but the checkbox does not "check" based on the "0" or "1" thats returned from the QUERY.</p>
 

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