ajax - JQuery Select Populate -
i have items on html
a input text (company) field , select (company_list)
when user types in text field want jquery use /home/searchsynonym/ names , display in select (the searchsynonym takes value user types , wildcard search , returns id , name )
can 1 , new ti jquery
leb
you need clarify in format searchsynonym return ids , names? in json? if in json, try following:
var companylist = $("#company_list"); $("#company").change( function(){ $.getjson("/home/searchsynonym/",{ query: $(this).val() }, function(response){ var responselist = ""; $.each(result, function(index, item){ responselist += "<option value='" + item.id + "'>" + item.name + "</option>"; }); companylist.html(responselist); }); });
this work if 'company' text field bears id="company" in tag decleration, 'company_list' dropdown bears id="company_list" in tag decleration , server end receives parameter "query" pulling records.
Comments
Post a Comment