Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

JQuery Drop Down Menu

Posted on 2012-03-20
1
Medium Priority
?
327 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

609 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