Solved

JQuery Drop Down Menu

Posted on 2012-03-20
1
316 Views
Last Modified: 2012-03-20
Hi,
I have a drop down menu with the following options in my HTML;

<select name="industry" id="industry" type="select">
<option value="" selected>Please select you industry:</option>
<option value="Agricultural">Agricultural</option>
<option value="Mining">Mining</option>
<option value="Industrial">Industrial</option>
<option value="Environmental">Environmental</option>
</select>

Open in new window


Now based on what the user selects, div's show and hide more form fields.
I have the menu working when the user selects either Agricultural or Mining.
Mining, Industrial and Environmental all display the same content so i was wondering how to write the statement in javascript if i wanted something like the below

if ($(this).val() == "Mining or Industrial or Environmental")

Below is the full code I'm using for the jquery menu.
I don't know much about java so any help would be apprieciated, thanks!

<script type="text/javascript">
$(document).ready(function() { $("#industry").change(function() { if ($(this).val() == "Agricultural") { $("#hide1").slideDown("fast"); } else { $("#hide1").slideUp("fast"); } } );

$("#industry").change(function() { if ($(this).val() == "Mining") { $("#hide2").slideDown("fast"); } else { $("#hide2").slideUp("fast"); } }); });
</script>

Open in new window

0
Comment
Question by:JiveMedia
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 37745637
something like : http://jsfiddle.net/JM4dr/1/
$(document).ready(function() { 
    $("#industry").change(function() { 
        if ($(this).val() == "Agricultural") {
            $("#hide1").slideDown("fast");
        }
        else {
            $("#hide1").slideUp("fast");
        }
        if ($(this).val() == "Mining" || $(this).val() == "Industrial" || $(this).val() == "Environmental" ) { 
            $("#hide2").slideDown("fast"); 
        }
        else {
            $("#hide2").slideUp("fast");
        }
    });
});

Open in new window


¿
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now