You could add another keyup-event-handler to the input field, and clear the id field. As long as that runs before the result-handler is setting the data, it should give you the result you need.
Jörn On Fri, Jan 23, 2009 at 5:09 PM, Styx <pawel.chuchm...@gmail.com> wrote: > > Hi. > > I have two fileds. For exmple: > > $("#name").autocomplete('seatch.php'); > $("#id").result(function(event, data, formatted) { > if (data) { > $("#id").val(data[1]); > } > > If i select sometfing in autocomplete field, my id field will have id > of this item. After submit I have two fields - one wieth name, and one > with id. I can for example update dabase use id. > > But if I write in autocomplete somethig, which isn't in result, my > function isn't triggered. If i edit existing data, after submit I have > field "id" with some value, and filed "name" with new value. I don't > know, that I shoul add my "name" to database, or do something else. > > What I should do to clear field "id" when "name" is write by me and > dosen't exist in result of 'search.php'? > > regards, > pch >