• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 330
  • Last Modified:

JQuery Drop Down Menu

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
JiveMedia
Asked:
JiveMedia
1 Solution
 
leakim971PluritechnicianCommented:
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now