I m adding DropDown in jsp page.
and m trying to redirect a page exact after index change without any button click.
How can i add it to jsp page?
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
$(function(){
$('com').bind('change', function () {
var value = $(this).val();
if(value==1) window.location = "servlet1?id=1";
if(value==2)window.location = "servlet1?id=2";
return false;
});
});
</script>
<body>
<select id="com">
<option></option>
<option value="1">Link1</option>
<option value="2">Link2</option>
</select></body>
Not working, is anything missing , plz
When i change index then i want to redirect to corresponding link/page.
Using jQuery you could do it as follows,
$(function(){
// bind change event to select
$('#ID_OF_select_ITEM').bind('change', function () {
var value = $(this).val(); // get selected value
window.location = someURL; // redirect based on the value
return false;
});
});
Just use '#com' instead of 'com' probably it will work
if still not working then let us know we have alternative for this task
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.