prasanna p

prasanna p

  • 1.3k
  • 470
  • 103k

How-to-assign-selected-value-from-auto-complete-extender

Sep 25 2016 5:20 AM
hi friends<br /> <br /> I am using auto complete extender using jquery through webservice. I have two textboxes.for both I am using autocomplete extender.<br /><div> Ex:</div><div><pre id="pre646208">Material group Material Name<br />&nbsp;MaterialGroup1 MaterialName1 <br /> &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; MaterialName2 <br /> MaterialName3 <br />MaterialGroup2 MaterialName4 <br />&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MaterialName5</pre> Here my question is when I select materialGroup1 in one textbox through autocomplete extender the corresponding materialnames(from MaterialName1 to MaterialName3) should be populated in auto completeextender in another textbox.<br /> <br /> how to achieve this using jquery.</div><div>here my jquery function is</div><div>&nbsp;</div><div>&nbsp;function SearchText() {<br /><br /> $(".autosuggest").autocomplete({<br /> <br /> source: function (request, response) { <br /> $.ajax({<br /> type: "POST",<br /> contentType: "application/json; charset=utf-8",<br /> url: "MaterialRequestForm.aspx/GetAutoCompleteData",<br /><br /> data: "{'MaterialName':'" + this.term + "'}",<br /> dataType: "json",<br /><br /> success: function (data) {<br /> if (data.d.length &gt; 0) {<br /> response($.map(data.d, function (item) {<br /> return {<br /> label: item.split('/')[0],<br /> val: item.split('/')[1],<br /> <br /> }<br /> }));<br /> }<br /> else {<br /> response([{ label: 'No Records Found', val: -1 }]);<br /> }<br /> },<br /> error: function (result) {<br /> alert("Error");<br /> }<br /> });<br /> },<br /> select: function (event, ui) {<br /> //if (ui.item.val == -1) {<br /> // return false;<br /> //}<br /> var disid = $(this).attr("data-id");<br /> $(".id-group").find(".col-md-12").each(function(){<br /> if (disid == $(this).find("input[type=text]").attr("data-id")) {<br /> $(this).find("input[type=text]").val(ui.item.val);<br /> }<br /> });<br /> <br /> }<br /><br /> });</div><div>&nbsp;</div><div>Here I am assigning material Id to textbox on selection of Material name.<br /> how to populate the data based on selected value in auto complete extender. &nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div>

Answers (2)