File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Input field autocomplete

 
Jason Dixon
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic