jquery javascript - clear checkboxes on changing autocomplete field -


i have below script:

$("#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] > 0) {                      $('#h09_1').attr('checked', 'checked');                  } else {                      $('#h09_1').removeattr('checked');                  }              }          });      } }); 

this has autocomplete field when text entered provides options database. works. on clicking option autocomplete, queries database function(get_as_09) , checks checkbox based on result.

again works 100%.

what want change though, when enter new value on autocomplete, must clear checkboxes before applying new database lookup logic check boxes.

i don't know add $('#h09_1').removeattr('checked');

thanks , regards...

any appreciated

update ripu

if(data:selectedobj.value.length ==0 ){$('#h09_1').removeattr('checked');};  $.post('get_as_09', {data:selectedobj.value},function(result) {         if(result[0] > 0) {           $('#h09_1').attr('checked','checked');        } else {           $('#h09_1').removeattr('checked');       }  });  

before line

$.post('get_as_09', {data:selectedobj.value},function(result) {  

check if value of data:selectedobj.value empty. if empty, don't need make post request, uncheck checkbox


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -