I'm looking for some tips and information because google isn't liking me with the results so I can' do much research. I have a select menu with some options for each module and what is supposed to happen is when the user clicks on Add and clicks Apply they are supposed to be taken to a certain page and when they click Edit they are supposed to be taken to a different page. How can I accomplish this with jQuery.
<select name="dropdown" class="fl-space">
<option value="0">choose action...&开发者_StackOverflow社区lt;/option>
<option value="add">Add</option>
<option value="edit">Edit</option>
<option value="delete">Delete</option>
</select>
Try this
var urlToNavigate;
$("select[name='dropdown']").change(function(){
switch(this.value){
case "add":
urlToNavigate = "addPageUrl";
break;
case "edit":
urlToNavigate = "editPageUrl";
break;
case "delete":
//Write delete logic here
}
});
$("#submit").click(function(){
if(urlToNavigate){
location.href = urlToNavigate;
}
});
精彩评论