【问题标题】:onchange event not working in dropdown listonchange 事件在下拉列表中不起作用
【发布时间】:2014-10-12 05:03:18
【问题描述】:

我正在尝试在下拉列表的 onchange 事件上导航到不同的 jsp 页面...

这是我的代码

<%@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>

我为下拉列表尝试了所有事件 onclick、onchange、onfocus,但似乎没有任何效果。如果我使用了错误的事件,请建议我使用正确的事件来导航到不同的页面...... ..

【问题讨论】:

标签: html jsp


【解决方案1】:

你不能像这样打电话给onChange。先通过这个JSP dropdownlist onChange

使用 jQuery。这对你有用

$('select[name=category_list]').on("change", function(e){
   //navigate to Test.jsp
});​​​​​​​​​​

【讨论】:

    【解决方案2】:

    下拉的onchange事件不会引起提交动作。您可以通过 onchange 访问脚本函数,而不是 jsp。

    【讨论】:

      猜你喜欢
      • 2021-11-07
      • 1970-01-01
      • 2021-01-23
      • 1970-01-01
      • 1970-01-01
      • 2016-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多