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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying select results using a form?

Status
Not open for further replies.

suzdee

Technical User
Jan 19, 2005
1
US
Hello,

I have a page which queries MySQL and displays a list of screening locations. I want the user to be able to select from a dropdown menu and sort the list by location city, meaning if they choose "City A", only locations in City A will appear on the page and the others go away. Same with "City B" Etc. Etc.

What's the simplest way to go about doing this? Would I use an if, else statement? I can't seem to figure it out.

Thank you!!

Sam
 
The problem is that you can't do this in a single run of a single script.

By the time your browser has rendered the page in its initial state, the script has already finished its run and the network connection between the server and the browser has been severed. To get the browser to change its display, you are going to have to use a combination of server-side (to provide content) and client-side (to provide reactions to user input) scripting.

One way is to trap a client-side "on change" event in the first dropdown. The code that handles the event could submit the form to a PHP script which will take the setting for the first dropdown to populate the second.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
If you truely want this to be done on the client side, this could be done with DHTML, but that would be a question for another section of the forums...
 
If this is done client-side, it's easy to make a script that views source and then finds the secret key.

You can either draw text on images, or you can have a list of keys and select a random.

you could also do this with <div> with contents and then move them around to make a key, though, that would be more time-consuming and less secure, as well as browser dependent.

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

Part and Inventory Search

Sponsor

Back
Top