jQuery UI autocomplete copy input value to another input -


i'm trying copy input value jqui autocomplete input, has autocomplete function enabled.

here's have in html

<label for="locationfrom">location</label> <input id="locationfrom" /> <label for="locationto">location</label> <input id="locationto" /> 

and js

$(function() { $('#locationfrom, #locationto').autocomplete({     source: [     "airport",     "downtown",     "street",     "city"             ],     minlength: 0 }) .focus(function() { var self = this;  window.settimeout(function() { if (self.value.length == 0)   $(self).autocomplete('search', ''); });})});  

i tried this, doesn't work

$('#locationfrom').change(function() { $('#locationto').val($(this).val()); }); 

here's fiddle

tnx

it seems jquery autocomplete dose not fire 'onchange' event; can use autocomplete change event solve this.

$(function () { $('#locationfrom, #locationto').autocomplete({     source : [         "airport",         "downtown",         "street",         "city"     ],     minlength : 0,     change : function () {         $('#locationto').val($(this).val());     } }) .focus(function () {     var self = this;      window.settimeout(function () {         if (self.value.length == 0)             $(self).autocomplete('search', '');     }); })}); 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -