Response title
This is preview!
<html> <head> <script src="http://code.jquery.com/jquery-1.10.2.js"></script> <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.js"></script> <script type="text/javascript"> $(function() { var Cities = [ 'Abu Dhabi', 'Abuja', 'Accra', 'Amsterdam', 'Addis Ababa', 'Baghdad', 'Baku', 'Bamako', 'Bangkok', 'Beijing', 'Cairo', 'Canberra', 'Caracas' ]; $('#dest').autocomplete({ source: Cities, minLength: 2, select: function (event, ui) { $(this).val(ui.item.value); $(this).blur(); $(this).focus(); //the second autocomplete var more=[ ui.item.value + ' Accommodation', ui.item.value + ' Restaurants', ui.item.value + ' Sights', ui.item.value + ' Transport' ]; $('#dest').autocomplete({ source: more, select: function (event, ui) { $(this).val(ui.item.value); } }); } }); }); </script> </head> <body> <div> <span><em><strong>City</strong></em></span> <br /> <span><input type="text" id="dest" name="dest" value="" placeholder="Type the name of the city ... " /></span> </div> </body> </html>
I dont want to use another input box for this.
$( "#dest" ).autocomplete( "disable" );
$( "
#dest
" ).autocomplete( "enable" );
$('#dest').autocomplete('disable');
//or try
$('dest').autocomplete('destroy');
$('#dest').autocomplete('enable');
}
If that doesn't work, another alternative is to merge the 2
selections into 1 selection array, use just 1 Autocomplete and put a
limit on the number displayed in the dropdown.
But that may
have some useability issues, particularly if the list of cities is
large.
© 2013 jQuery Foundation
Sponsored by and others.