nrking83
asked on
how can I display text based on a dropdown box selection?
Hello,
I'm trying to something rather simple.. at least it seemed simple. On my html form there is a drop down box with store locations, just the city their located in. When the customer selects what city I want a DIV or whatever else might work to display the full address and contact information. How can I do this?
Thanks!
I'm trying to something rather simple.. at least it seemed simple. On my html form there is a drop down box with store locations, just the city their located in. When the customer selects what city I want a DIV or whatever else might work to display the full address and contact information. How can I do this?
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this
function change_city(){
elm = document.getElementById('city_drop_down');
switch(elm.selectedIndex){
case 0://If the person selects the first option
document.getElementById('city_info').innerHTML = 'full address and contact information';
break;
case 1:
document.getElementById('city_info').innerHTML = 'full address and contact information of the other city';
break;
}
}
<select id="city_drop_down" onchange="change_city();">
<option value="0">0</option>
<option value="1">1</option>
</select>
<div id="city_info"></div>//the information will apear here
ASKER