Solved

JQuery Drop Down Menu

Posted on 2012-03-20
1
324 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

687 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