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

select option

Status
Not open for further replies.

calvi

Technical User
May 26, 2003
87
NL
i use a dropdown list with <select> and <option>.
I have 2 dropdown list. example i have a list of Country and a list of city. I want to relate these two lists. If a user select a country than i want the other dropdown list to be filled with the cities of that selected country. and vice versa if I select a city, then the country dropdown list will selected/filled with the country of that city. Do you know how i can do this? with html or javascript or xml?
 
You can do this using javascript - I would suggest you use the onchange event on the <select> to fire off an AJAX call to the back-end and use the returned data to populate the second drop-down.

It might be worth giving the second drop-down an ID so you can easily update it's contents using document.getElementById()

Cheers,
Jeff


[tt]Jeff's Page [!]@[/!] Code Couch
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Also take a look at the FAQs in the JavaScript forum (forum216). There are several available which show how to "link" select elements, including one of mine, faq216-6294

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top