Selecting appropriate town through a form?

admin

Administrator
Staff member
Ive created a form to people to register to my site.

they can either select: scotland, england or wales.
but below that i have a drop down with a list of towns.

How can i have it so that it i select Scotland from the drop-down, the drop-down list below will only have the town from that country listed?

The form is done in HTML but is sent through PHP

thanks in advance

Here is my form: <!-- m --><a class="postlink" href="http://www.popcop.co.uk/verify/sign_up.phpyour">http://www.popcop.co.uk/verify/sign_up.phpyour</a><!-- m --> going to have to use java script to detect what country the person selects and have 3 arrays with all the towns listed

if they select england
loop through array and display all towns in array.
with the amount of towns

its going to take a lot of typing to get all the towns down but the code logic is quite simple

i would probably use the onfocus event handlerYou'll need to find a UI (user interface) code and make the form with that.your going to have to use java script to detect what country the person selects and have 3 arrays with all the towns listed
Or, since you are already using PHP, you can have the user select the country, post the form (onchange), and return a new page with the applicable down-down list.

Saves a whole bunch of javascript. :)Or, since you are already using PHP, you can have the user select the country, post the form (onchange), and return a new page with the applicable down-down list.

Saves a whole bunch of javascript. :)


the only problem with that is your starting to go into page transitions and i know personally i have problems with them on other sites when they do this.

but yes you have the option of server side or client sideYou could use AJAX making and amalgamation of Javascript and PHP but it's a pain in the @rse for something which you could do a lot easier with one or the other.You might look at this (<!-- m --><a class="postlink" href="http://javascript.internet.com/forms/country-state-drop-down.html">http://javascript.internet.com/forms/co ... -down.html</a><!-- m -->).
 
Back
Top