We help IT Professionals succeed at work.

how can I display text based on a dropdown box selection?

nrking83
nrking83 asked
on
357 Views
Last Modified: 2012-05-09
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!
Comment
Watch Question

Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Perfect!!!
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

Open in new window

Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.