var autoComplete,sebox=$("#searchb"), dlg = $("#formx"); var itemc=$("#itemb"); input = $(".title", dlg) //$("#itemsearch2") sebox.mcautocomplete({ // These next two options are what this plugin adds to the autocomplete widget. showHeader: true, columns: [ //{ name: 'Item', width: '150px', valueField: 'name' }, { name: 'Name', width: '150px', valueField: 'name' }, { name: 'Email', width: '150px', valueField: 'email' }, { name: 'Phone', width: '150px', valueField: 'phone' }, /* { name: 'Internal', width: '120px', valueField: 'intname' }, { name: 'Category', width: '120px', valueField: 'category' }, { name: 'itemid', width: '80px', valueField: 'itemid' }, {name: 'Price', width: '120px', valueField: 'price' } */ ], /*, { name: 'Tax', width: '120px', valueField: 'gst' }*/ // Event handler for when a list item is selected. select: function (event, ui) { this.value = (ui.item ? ui.item.name : ''); //$('#results').text(ui.item ? 'Selected: ' + ui.item.name + ', ' + ui.item.adminName1 + ', ' + ui.item.countryName : 'Nothing selected, input was ' + this.value); //$('#results').text(ui.item ? 'Selected: ' + ui.item.name : 'Nothing selected, input was ' + this.value); //$('#selitem').text(ui.item ? 'Selected: ' + ui.item.name : 'Nothing selected, input was ' + this.value); //$('#seitemsearch').val('') $('#searchb').val('') //$("#itemname").val(ui.item.name) $("#cname").html(ui.item.name) //$("#itemid").val(ui.item.itemid) $("#caddress").html(ui.item.email) $("#cphone").html(ui.item.phone) //$("#itd91").val(ui.item.itemid) //$("#tax").val(ui.item.gsty) //$("#itx95").val(ui.item.gsty) //$("#rate").val(ui.item.price) //$("#itr94").val(ui.item.price) //$('#qty').focus(); //$('#qty').focus(); if(ui.item.gsty.length>1){ } var dl = ui.item.gsty var sel = document.getElementById('mprice'); for(var i = 0; i < dl.length; i++) { var opt = document.createElement('option'); opt.innerHTML = dl[i]; opt.value = dl[i]; sel.appendChild(opt); } return false; }, // The rest of the options are for configuring the ajax webservice call. minLength: 1, source: function (request, response) { $.ajax({ url: 'feed/feed_customers.php', dataType: 'jsonp', data: { featureClass: 'P', style: 'full', maxRows: 12, name_startsWith: request.term, username: "demo" }, // The success event handler will display "No match found" if no items are returned. success: function (data) { var result; if (!data || data.length === 0 || !data.geonames || data.geonames.length === 0) { result = [{ label: 'No match found.' }]; } else { result = data.geonames; } response(result); } }); } }); autoComplete = sebox.mcautocomplete("widget"); autoComplete.insertAfter(dlg.parent()); sebox.mcautocomplete( "option", "appendTo", "#formx" ); //******************************* //******************************* //******************************* //******************************* //******************************* //******************************* //******************************* //******************************* //******************************* //******************************* //******************************* //******************************* //******************************* itemc.mcautocomplete({ // These next two options are what this plugin adds to the autocomplete widget. showHeader: true, columns: [ { name: 'Item', width: '250px', valueField: 'name' }, { name: 'tax', width: '80px', valueField: 'tax' }, {name: 'Price', width: '120px', valueField: 'price' } ], /*, { name: 'Tax', width: '120px', valueField: 'gst' }*/ // Event handler for when a list item is selected. select: function (event, ui) { this.value = (ui.item ? ui.item.name : ''); //$('#results').text(ui.item ? 'Selected: ' + ui.item.name + ', ' + ui.item.adminName1 + ', ' + ui.item.countryName : 'Nothing selected, input was ' + this.value); //$('#results').text(ui.item ? 'Selected: ' + ui.item.name : 'Nothing selected, input was ' + this.value); //$('#selitem').text(ui.item ? 'Selected: ' + ui.item.name : 'Nothing selected, input was ' + this.value); //$('#itemsearch').val('') $('#itembhb').val('') /* //$("#itemname").val(ui.item.name) $("#itm92").val(ui.item.name) //$("#itemid").val(ui.item.itemid) $("#itd91").val(ui.item.itemid) //$("#tax").val(ui.item.gsty) $("#itx95").val(ui.item.gsty) //$("#rate").val(ui.item.price) $("#itr94").val(ui.item.price)*/ //$('#qty').focus(); $("#particulars").val(ui.item.name) //$("#cgst").val(ui.item.tax/2) //$("#sgst").val(ui.item.tax/2) $("#tax").val(ui.item.tax) $("#imid").val(ui.item.ilid) $('#qty').focus(); if(ui.item.gsty.length>1){ } var dl = ui.item.gsty var sel = document.getElementById('mprice'); for(var i = 0; i < dl.length; i++) { var opt = document.createElement('option'); opt.innerHTML = dl[i]; opt.value = dl[i]; sel.appendChild(opt); } return false; }, // The rest of the options are for configuring the ajax webservice call. minLength: 1, source: function (request, response) { $.ajax({ url: 'feed/feed_listitems.php', dataType: 'jsonp', data: { featureClass: 'P', style: 'full', maxRows: 12, name_startsWith: request.term, username: "demo" }, // The success event handler will display "No match found" if no items are returned. success: function (data) { var result; if (!data || data.length === 0 || !data.geonames || data.geonames.length === 0) { result = [{ label: 'No match found.' }]; } else { result = data.geonames; } response(result); } }); } }); autoComplete2 = sebox.mcautocomplete("widget"); autoComplete2.insertAfter(itb.parent()); itemc.mcautocomplete( "option", "appendTo", "#formx" );