views:

41

answers:

2

I'm trying to insert a variable within a div (#cityInput) upon jQuery autocomplete selection. What am I doing wrong?

var options = ["California", "Seattle", "Portland", "San Francisco"];

 $(function() {
    $("#citySelect").autocomplete({
    source: options,
    minLength: 2,
    select: function() { 
     $('#chooseCity').dialog('close'); 
     $('#cityInput').append('airline');
     },
    });
 });
A: 

For one thing, you have comma after the last option (select).
That probably gives your javascript error. (I would recommend some tool, like firebug, for monitoring errors in javascript)

edit
Here's a live example. I enter Se in input, click on appeared Seattle choice and get alert with the city I selected.
Autocomplete works.

Nikita Rybak
Thanks. I've very new to jQuery. I fixed the comma, but still trying to insert a selected variable into a div.
Mik
A: 

You have an extra comma:

 },
  ^
Sarfraz