views:

22

answers:

1
    $(function() {
    var availableTags = ["ActionScript", "AppleScript", "Scheme"];
      $("#tags").autocomplete({
        source: availableTags
      });

I don want the values inside the tags. i have a JS page i need to make a function for connecting my DB to the auto complete plugin. How can i do it suggestions Please.

Thanks in Advance..

+3  A: 

You can not connect to a database using only JavaScript and you should never show your database values in JavaScript as everybody can read them.

You have to use a server side script to connect to your database, resolving the autocomplete values and responding them to the autocomplete plugin.

So in gerenal you don't use a local "source" with the suggestions, but a server side script and getting the values through ajax calls:

$("#tags").autocomplete('url_to_server_side_script');

EDIT: So i looks like it is a JSP page. After getting the values wihtin the function, you have to create an output (and use the "reponse" to send it to the client) with each value in a new line looking like this:

ActionScript
AppleScript
Scheme

You can even use HTML to markup the match of the query string (let's asume it was "Sc"):

Action<em>Sc</em>ript
Apple<em>Sc</em>ript
<em>Sc</em>heme
Kau-Boy
@Kau thanks---yes in server side scripting i created a connection to the table which i need to be displayed in the auto complete option. the function name for that is public Employee getEmployeeName(string name) throws ClassNotFoundException, SQLException {--- under this function i got my values now should i connect this in the place of url. Can u suggest me the way to complete it??
Gladiator