Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

autocomplete drop down list 3

Status
Not open for further replies.

dontyell

Programmer
Feb 28, 2003
10
US
Hi,

I am working on a web page using php. I need an autocomplete drop down list, i.e. when I type "a", all the entries beginning with "a" show in order, then I type "n", then all entries begins with "an" show in order, and so on.

I have used two ways to do autocomplete list in web pages before:

1. I have built an ActiveX control of an autocomplete combobox in VB, then use it is ASP page.
2. I have used Javascript building such a list.

Both methods work well. However, the problem with method 1 is that user needs to allow the IE to download the control, which my boss does not like. The problem with method 2 is that it is way too slow when I got several thousand of entries in the list.

My boss wants to me try sth in PHP. I've been searching online cannot find a way to do it in PHP yet. Anyone has any suggestion or advice, I'll really appreciate it.

Thanks very much.
Cindy
 
Well, you are right. My idea was: you type one or more letters (like herman75 suggested) then push a submit button and make a search.
 
I'm intrigued by LaundroMat's note. This effect may have been caused by smarter-than-the-average-bear browsers that auto-complete form fields (not a function of the web server). Can you offer a link to demonstrate this LaundryMat?

The only way I can imagine to work PHP's server side functions into this is to use iframes.

- - picklefish - -
Why is everyone in this forum responding to me as picklefish?
 
it's I think also possible if ther is a seperate form field where you can type in and that another form field dynamicaly changes it's result list. and as said you can then use iframes or frames to present the datalist in

 
Hello, I'm actually encountering exactly the same problem as you. I'm writing you this message because I'm about to found the solution (I have found it but I want to improve it). If you are interested I think I will be able to give you the code in one or two weeks at most (I'm sorry but I have now a lot of work). The solution is javascript: what you have to do is precaching the data, so searching the good list index is quicker. I have implemented a solution with the worst algorithm that I could imagine (to test the worst speed). I have tested the script with about 6200 entries and I can type quite as fast I'm able to do it. If you are interested by my solution just answer to this thread and I'll send it when I have implemented a best searching algorithm (bissection algorithm)
 
Sure a well performing javascript solution could always be practical.
 
I wonder if there might be something like this in the DHTML part of
though, your list would have to be populated by php!
It would also be dependent on browser-versions, etc.
I however think that maybe your work has standarized installations and the users can not choose which browser they want to use?

ps. I dont know if there is such an script on DD, but I know there are lots of other client-side thingies there.

I personally stay away from such things, as I think that if the users know what they are able to use the keyboard to search.

client-side just gives more fuzz, when something is not working, since someone is using some other version or he/she disabled javascript..

"help, I Have an error"
-"which error?"
"I dont know!! something error"

I would rahter make some FAQ page about how to search for users and link up a "help" link, somewhere near the search-functionality.

Personally, I dont bother with such, I rather bother with making FAQ for important functions, like "log into mail", etc.

Good luck!
And, dont get whipped into doing something which will only make everything slower and more limited to a handfull of visitors.

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top