Jump to content

while typing auto suggest text for input field.


jasonc

Recommended Posts

Just noticed on some sites like facebook, that while typing in say the search box you are given names to select from before you have finished of typing it all in.

 

i wish to have a method to say have members type in a username they want and it show if the username if available or not while they type it in. so it would have to access the mysql database to check the name as it is typed?

 

how is this done.

 

 

sorry i have posted it in this forum, i do not know the method to post it in the correct forum, please move to the correct forum that it should be in.

 

thanks in advance for your help.

There should be many resources for doing what you ask. I prefer using prototypejs (and script.aculo.us for effects) framework as it provides a really easy environment. The username availability can be easily achieved, but what I suggest is run the check on a button click. Basically:

 

- The button calls a javascript function with the written username as parameter

- The javascript makes an ajax call to a php script and sends the username to it (as e get variable)

- The php script checks the database for that username and prints back if it exists or not

- The javascript function catches the response and shows it in an html portion of your site

 

That's basically a simple request and response of javascript and a php script. For further code and explanation, you can find a lot of answers in google by searching for example: "php ajax username availability". Hope this clears out your ideas.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.