Two Laptop Bag*
The moose likes HTML, CSS and JavaScript and the fly likes Input field autocomplete Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Input field autocomplete" Watch "Input field autocomplete" New topic
Author

Input field autocomplete

Jason Dixon
Greenhorn

Joined: Dec 19, 2004
Posts: 2
I'm attempting to incorporate a feature similar to the ones found in the beta Google Suggest (http://www.google.com/webhp?complete=1&hl=en) or Gmail, where the user's input is dynamically searched against a known list of values, pulled in via XmlHttpRequest. In our case, we're trying to create an alternative to a drop-down of 300-1000 names.

I read the Slashdot post this weekend about how Chris Justus "reverse engineered" the Google Suggest interface (http://serversideguy.blogspot.com/2004/12/google-suggest-dissected.html), and feel this would be perfect for our needs. Unfortunately, my Javascript knowledge is basically non-existent. If anyone would be willing to help me out on this, I'd be greatly appreciative.

P.S. Eric Pascarello, I know you're out there. FYI, I picked up your book last week at B&N.

Thanks,
Jason
[ December 19, 2004: Message edited by: Jason Dixon ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I was trying to avoid you! lol! JK

I really like this script here: http://codeproject.com/jscript/jsactb.asp

Another one here: http://www.webreference.com/programming/javascript/gr/column5/

but those are going off of an array.

After I get done wrapping gifts I just bought for my woman I will read the article.

Eric
[ December 19, 2004: Message edited by: Eric Pascarello ]
Jason Dixon
Greenhorn

Joined: Dec 19, 2004
Posts: 2
Originally posted by Eric Pascarello:

I really like this script here: http://codeproject.com/jscript/jsactb.asp

<snip>
but those are going off of an array.

[ December 19, 2004: Message edited by: Eric Pascarello ]


Yeah, that looks perfect! I don't mind it being in an array... if I need to, I can pre-populate it with the available names (at the time of the request). Ideally, I'd like to incorporate XmlHttpRequest to pull the list dynamically, but this might cause more load than the administrators will allow.

In a perfect world, the input would have the ability to use a different value than what is in the input field (like a drop-down, for example). I'd like to pass a user ID rather than the strings in the array. Can you think of a way of doing this?

Thanks,
Jason
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
The one thing you can do is set up either a 2D array or a "parallel array" with the other values. Somewhere in that code is a function that sets the value in the text box. In that function, we need to grab the value from the second array and fill in the hidden text box.

(sent you files via email)

Eric
 
Don't get me started about those stupid light bulbs.
 
subject: Input field autocomplete
 
Similar Threads
problem about mysql driver
Morality: relative or absolute?
Scrollable list like google suggest
Google Select
My voting experience