javascript - Jquery ui autocomplete not fill -


I'm new to jQuery and jQuery UI.

I autocomplete with Dynamic Rows in the table with the remote Jason.
The problem is: everything works, but for some reasons, the input code is not full.
Curiously, if I type hardcode # code0 or # code1 in the selected area, it works.
But it seems that # code + i is not another strange thing recognized in the selection that $ ("# product" + i) works is.

Can a JS help in getting started?

  $ (document) .ready (function () {var i = 0; $ ("# add_row"). Click (function () {$ ('# addr' + i) Html ("& lt; td>" + (i + 1) + "   gt; & lt; / td & gt; Ld; td & gt; input id = 'code' + I + "'name $' ('# Tab_logic') = 'code' + i +" 'type =' text 'placeholder =' codic 'class = 'Form-control' to read only = 'Readable' & Gt; ;); ('& lt; tr id = "addr' + (i + 1) + '" & gt; & lt; / tr & gt;'); $ ("# Product" + i). Autocomplete ({source: function (request, response) {$ .ajax ({url: "productsearch.php", datatype: "Jason", data: {word: request.term} Success: Work (data) {response ($ .max (data, function (item) {return {label: item.text, id: item.id, code: item.id};}));}});} , Minimala: 2, Select: Function (Event, UI) {var codice = "$ code" + i; $ ('#Codice') Val (ui.item.id). }}); I ++; }); $ ("# Delete_row"). Click (function () {if (i & gt; 1) {$ ("# addr" + (i-1)) .HTML (''); i--;}}); $ ("#products" + i) Autocomplete ({source: function (request, response) {$ .ajax ({url: "productsearch.php", datatype: "Jason", data: {word: request.term}, success: function (data) { Feedback ($ .max (data, function (item) {returns: {label: item. Text, id: item.id, code: item.id};})))}}}); }, Minimala: 2, Select: Function (Event, UI) {$ ("# code" + i) .val (ui.item.id);}}); I ++; }); });  
  & lt; Tbody & gt; & Lt; Tr id = 'addr0' & gt; & Lt; TD & gt; 1 & lt; / TD & gt; & Lt; Td> & Lt; Input id = "Product 0" type = "text" name = 'product0' placeholder = 'Digitized IL code o il not dell prodot' class = "form-control" & gt; & Lt; / Td> & Lt; Td> Input id = "code0" type = "article" name = 'code0' placeholder = 'codeic' class = "form-control" read-only = "readable" & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; Tr id = 'addr1' & gt; & Lt; / TR & gt; 

One thing to make sure is that your selection event There is a bug in the handler: Choose

 : function (Event, UI) {var codice = "$ code" + i; $ ('#Codice') Val (ui.item.id). }  

You create a variable for the jquery selector and then do not use it. You can not update your input value, whose ID is "Function" with this function. Instead, it is important to:

  select: function (event, UI) {var codice = "# code" + i; $ (Codice) .val (ui.item.id); }  

Fix it and see if your problem gets resolved.


Comments