?
Solved

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
1
Medium Priority
?
454 Views
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?
0
Comment
Question by:cbrune
1 Comment
 
LVL 45

Accepted Solution

by:
Chris Stanyon earned 2000 total points
ID: 38389192
I guess you could bind the change event and 'switch' either the value or the text and call your functions from there

//html
<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>
</select>

//jQuery
$(document).ready(function() {
	$('#myDropdown').change(function() {

	switch($(this).val()){
		case '1':
			alert ("Number 1");
			break;
		case '2':
			alert ("Number 2");
			break;
		case '3':
			alert ("Number 3");
			break;
		default:
			alert ("Something else");
	}
	});
});

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

850 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