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
 
sleipnir214:

So you mean it is impossible to do it in PHP at all, right?

 
sleipnir214:

So do you have any good suggestion on how to build the autocomplete list except for the Javascript and ActiveX control?
 
If you really have thousand of entries why don't you send a request to the server for any new typed letter: in this way you can send to the client pure HTML code and don't have the problem with downloading ActiveX controls or javascript activation and so on...and then you limit the quantity of data to send to the client.
 
you can perhaps use the onchange function in combination with javascript

in this thread is an example of one input that defines dynamicaly the output for the second select list

thread434-743971 the example is not working again since the hosting went down.

you can make an alternative by using a normal text field where you type the letters in and then the select automaticaly generates the query again and again after every letter typed.the remaing results are shown in the select list
 
sc7090 & hos2 :

Your suggestion on "send a request to the server for any new typed letter" sounds good. Can you provide a bit more details like some sample code on that? I am wondering how to actually get the newly typed letter if not using Javascript?
 
If you have a dropdown with several thousands of items a dropdown doesn't sound like the right interface. Why not let people enter a few characters (with wildcards if you want) and then press a searchbutton, which will populate your dropdown with only the values that match. I know phpBB uses a system like that to select users (for example in the admin panel to select the user who's profile to edit).

If you are interested I suggest you download and install phpBB and have a look.
 
herman75:

Thanks for the suggestion. Actually I had this search functionality on my page too. It is an intranet application so people always ask everything. so I still have to implement the autocomplete drop down list.

 
why ?? what is the return of investment compared to the old situation ???

this question reminds me of 'fight club' where the manager in charges asks the most important question of them all 'can the buttons also be made in pastell colors?'

;)
 
Sounds to me you let yourself be pushed around. Sometimes you have to say, that can't be done on the current system. besides, if it is for an intranet what is the problem of using an ActiveX component?
 
or make a calculation of how much that gadget is going to cost is sometimes also very effective ;) and ofcourse the other sollution which is 1/10 of the former mentioned price
;)
 
Well, it was an intranet application in ASP that I developed a while ago. I am asked to rewrite the whole thing in PHP and it is gonna be an internet application. All the functionalities are supposed to be there.
 
I see.

Well you will always end up with a clientside solution. These include javascript and ActiveX. The only alternatives I can think of for these are Java applet, Flash applet etc., but these have the same drawbacks as javascript. In other words, if javascript isn't quick enough and you don't want to use things like ActiveX you're stuck.
 
the power of the human being is that it can quickly adapt to changing environments.

so screw his question and say that this is a different system with different methods which will benefit much more than just some lame neat looking activeX option which doesn't work with php. furhter on you can stat ofcourse that it's not platform independent anymore which will lead to much more expenses ;)
 
Thanks guys, for all your suggestions here. Well, the programmer's life is real miserable.

Technically I will stick to Javascript.
 
Just a quick addendum to this: I've seen that the mysql website ( has a dropdown list like the one you want to create. It's somewhere in the documentation section; maybe you could have a look and see how they did it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top