jquery - I want to wire a dropdown statement to have a different event fire for each selection made using a switch statement.

Posted on 2012-09-11
Last Modified: 2012-09-14
I want to wire a dropdown statement to have a different event fire for each selection made using a switch statement and have it show different dialogs for each statement made.. these dialogs will fire different controller actions.. Can someone please help me on doing this when the document loads?
Question by:cbrune
    1 Comment
    LVL 42

    Accepted Solution

    I guess you could bind the change event and 'switch' either the value or the text and call your functions from there

    <select id="myDropdown">
    	<option value="1">1</option>
    	<option value="2">2</option>
    	<option value="3">3</option>
    	<option value="4">4</option>
    	<option value="5">5</option>
    	<option value="6">6</option>
    $(document).ready(function() {
    	$('#myDropdown').change(function() {
    		case '1':
    			alert ("Number 1");
    		case '2':
    			alert ("Number 2");
    		case '3':
    			alert ("Number 3");
    			alert ("Something else");

    Open in new window


    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    jquery 3 and protoype 9 24
    jQuery-Validation-Engine with steps 13 32
    Handling arrays 14 28
    jquery not selector 1 6
    Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question ( on how to make a page show some balloons animate up a page…
    Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
    The viewer will learn how to dynamically set the form action using jQuery.
    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)

    732 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