javascript - How to detect jQuery UI autocompleted field has changed not from list? -


I have a simple input text, which is filed with the jquier autocomplete function. I have some selectable items and when I have set myself a field called "field", then I have chosen it, after which I manually rename the item. This will be a new one, why do I need to save to the database? Can I somehow change the input text field?

I want to set the designated "pid" to empty.

Here is my HTML code:

  & lt; Input type = "text" name = "pid" id = "pid" & gt; & Lt; Input type = "text" name = "name" id = "name" & gt;  

Here is a Java code:

  $ ('# name')). Autocomplete ({source: function (request, response) {$ .exe (error: function (e, f, g) {}})}, ajax ({url: myurl, data: mydata, type: 'get', success : Function (data) {response (data.mydat);}, MinNamban: 1, Select: Function (Event, UI) {$ ('# PID') Val (ui.item.id); $ (' # Name '). Val (ui.item.name);}});  

So I can somehow find out that #name has changed, but auto-complete Not listed?

Code added here to update this database If the name is changed and not equal to one set, then autocomplete

example code below:

  var source = []; Var mapping = {}; var for trackName; (var i = 0; i & lt; compName .length; ++ i) {source.push (compName [i] .id); mapping [compName [i] .id ] = CompName [i] .value;} $ ("# Compid"). Autocomplete ({source: source, minlength: 1, select: function (event, ui) {$ ("# compName"). Val ( Mapping [ui.item.value]); TrackName = mapping [ui.item.value];}}}; $ ("# CompName") Change (function () {if ($ ("$ compName"). Val ()! = TrackName) {Warning ('name changed, fire Ajax and update db');}});  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -