burnside Posted May 29, 2008 Share Posted May 29, 2008 Hey all, i have a question but not sure if its a php question or not, Anyway here goes, i have a text box, i was just curious how would i do it so if you started to type something in it a username for example, it would bring i list of all the username starting with the first letter of the work, for example, 3 users, Adam, Andy, Chris so if i type A in the text box Adam & Andy will populate a drop down box? sorry if you cant understand what im trying to say, i think you tube does it when your searching on there site, Also sorry if in wrong forum. Quote Link to comment Share on other sites More sharing options...
PromaneX Posted May 29, 2008 Share Posted May 29, 2008 The front end (the text box) would need to use javascript and you could write a simple php script for the backed (have it perform a mysql query for WHERE username LIKE '$input%' (remember to use mysql_escape_string on $input, though). your textbox would need to fire an ajax request to the php script on its OnChange event and then parse the returned results (you could use json or xml, or even simply CSV) and list these results in a drop down menu below the text box. There are pre-made scripts about on the net though to save you the hassle... http://www.dhtmlx.com/docs/products/dhtmlxCombo/index.shtml Quote Link to comment Share on other sites More sharing options...
burnside Posted May 29, 2008 Author Share Posted May 29, 2008 ill give that site ago, you got any other examples? Quote Link to comment Share on other sites More sharing options...
PromaneX Posted May 29, 2008 Share Posted May 29, 2008 Depending on how far you want to take it you could use extjs , but it may be a little heavy for what you want http://extjs.com/deploy/dev/examples/form/combos.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.