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
Solved

JQuery Drop Down Menu

Posted on 2012-03-20
1
321 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

828 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