[NWS] Select Boxes question
Moderator: General Moderators
[NWS] Select Boxes question
Hello,
I have 2 select boxes state/county and country. I want if a user select the country he lives in then the states/countys must be showed in the county select box. All the data is stored in a database.
Can someone helps me with this?
Cheers
Kris
I have 2 select boxes state/county and country. I want if a user select the country he lives in then the states/countys must be showed in the county select box. All the data is stored in a database.
Can someone helps me with this?
Cheers
Kris
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
Javascript requred:
example : http://www.mattkruse.com/javascript/dynamicoptionlist/
You could get the options in PHP and place them as a javascript array in the page.
Regards
example : http://www.mattkruse.com/javascript/dynamicoptionlist/
You could get the options in PHP and place them as a javascript array in the page.
Regards
Ya, javascript. Something like:
Code: Select all
<script>
function update_state(s_country)
{
if(country == "Canada")
{
var wrapper = document.getElementbyID('state_wrapper');
......
//go about re-writing the innerHTML of wrapper
}
.......
}
</script>
<select name = "country" onChange = "update_state('this.value')">
......
</select>
<div id = "state_wrapper">
<select name = "state">
........
</select>
</div>Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
Eek, sorry Pickle but doesn't InnerHTML throw some errors depending on what browser you have. There are far easier ways of doing it as shown by the link which use only core javascript that every browser (with javascript switched on) is OK with.
Now thats a though Wizzard, have you got a solution if users haven't swicthed on javascript?
Now thats a though Wizzard, have you got a solution if users haven't swicthed on javascript?
[NWS] link its something like this i want the state / province and country select box. Thats easy for my visitors. I have taked this one out of the adultfriendfinder website as example its not mine 
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
from another thread:
nigma wrote:Found what I was looking for:
http://www.mattkruse.com/javascript/dynamicoptionlist/
http://www.quirksmode.org/js/options.html
Edit: this helped the most http://www.felgall.com/jstip22.htm