faqts : Computers : Programming : Languages : PHP : Common Problems : Forms and User Input : URLs and Post or Get Methods

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

10 of 15 people (67%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

I have a drop down box populated with names of towns from my db (MySQL). My question is how do I select a town and then go to that page.

Feb 10th, 2004 07:04
Ivars Kalnins, John Clarke,


You need to have your drop-down box redirect to other page when it's
value (selection) changes.
This is done as follows:

<select name="city"
onChange="document.location='city.php?id='+this[this.selectedIndex].value;">
<option value="1">London</option>
<option value="3">Berlin</option>
...
</select>

In the resulting page (city.php) you would read the $_GET['id'] variable
to display the right content.