-1

I am trying to navigate to different jsp page on the onchange event of a dropdown list...

This is my code

<%@page import="java.util.*"%>
<html>
<head>
<title>Student Registration Form</title>
<style type="text/css">
h3{font-family: Calibri; font-size: 22pt; font-style: normal; font-weight: bold; color:SlateBlue;
text-align: center; text-decoration: underline }
table{font-family: Calibri; color:white; font-size: 11pt; font-style: normal;
text-align:; background-color: SlateBlue; border-collapse: collapse; border: 2px solid navy}
table.inner{border: 0px}
</style>
</head>

<body>
<h3>Select Product</h3>
<form action="retrieve_product" method="POST">

<table align="center" cellpadding = "10">

<tr>
<td>Select product to update</td>

<td>
<select name="category_list" onchange="Test.jsp">

<option>Option1</option>
<option>Option2</option>

</select>
</td>
</tr>

<!----- Submit and Reset ------------------------------------------------->
<tr>
<td colspan="2" align="center">
<input type="submit" name="UpdateProduct" value="Update">
<input type="reset" value="Reset">
</td>
</tr>

</table>

</form>

</body>
</html>

I tried all the events onclick, onchange, onfocus for a dropdown list but nothing seems to be working..If I am using the wrong events please suggest me the right one to navigate to a different page........

user3834217
  • 11
  • 1
  • 1
  • 7
  • See answers to previous similar/duplicate questions: - http://stackoverflow.com/questions/12388954/redirect-form-to-different-url-based-on-select-option-element - http://stackoverflow.com/questions/7562095/redirect-on-select-option-in-select-box - http://stackoverflow.com/questions/580281/redirect-automatically-when-selecting-an-item-from-a-select-drop-down-list – t0r0X Aug 19 '14 at 07:23

2 Answers2

0

You can't call onChange like this. Go thru this first JSP dropdownlist onChange

Use jQuery. This will work for you

$('select[name=category_list]').on("change", function(e){
   //navigate to Test.jsp
});​​​​​​​​​​
Community
  • 1
  • 1
Khaleel
  • 1,212
  • 2
  • 16
  • 34
0

The onchange event of the drop-down does not cause a submit action. You can access a script function via onchange, not a jsp.

Ravi Tiwari
  • 946
  • 8
  • 17