jquery javascript - clear checkboxes on changing autocomplete field
<p>I have the below script:</p>

<pre><code>$("#product1").autocomplete({
     source: "get_sku_family",
     messages: {
         noResults: '',
         results: function () {}
     },

     select: function (event, ui) {
         var selectedObj = ui.item;

         $.post('get_as_09', 
             {
                 data: selectedObj.value
             }, 
             function (result) {
                 if (result[0] &gt; 0) {
                     $('#h09_1').attr('checked', 'checked');
                 } else {
                     $('#h09_1').removeAttr('checked');
                 }
             }
         });
     }
});
</code></pre>

<p>This has an autocomplete field that when text is entered provides options from a database. this works. then on clicking an option from the autocomplete, it queries the database with a function(<code>get_as_09</code>) and checks the checkbox based on the result.</p>

<p>Again this works 100%. </p>

<p>What I do want to change though, is that when I enter a new value on the autocomplete, it must clear the checkboxes before applying the new database lookup logic to check the boxes.</p>

<p>I just don't know where to add the <code>$('#h09_1').removeAttr('checked');</code></p>

<p>Thanks and Regards...</p>

<p>any help appreciated</p>

<p><strong>UPDATE</strong> Ripu</p>

<pre><code>if(data:selectedObj.value.length ==0 ){$('#h09_1').removeAttr('checked');};
 $.post('get_as_09', {data:selectedObj.value},function(result) { 

      if(result[0] &gt; 0) {
          $('#h09_1').attr('checked','checked');
       } else {
          $('#h09_1').removeAttr('checked');
      }
 }); 
</code></pre>
