如何在jsp页面中从表达式标签到javascript获取值以进行验证?
我需要获取javascript函数中的值,并需要从javascript提交页面如何在jsp页面中从表达式标签到javascript获取值以进行验证?,javascript,jsp,Javascript,Jsp,我需要获取javascript函数中的值,并需要从javascript提交页面 我正在使用struts2框架。如果我正确理解了这个问题,您需要将值传递给javascript函数。您可以通过对代码进行以下更改来做到这一点 将javascript函数更改为: function redirect(){ var a = document.getElementById("id").value; alert(a); } 并将重定向作为 function redirect(id
我正在使用struts2框架。如果我正确理解了这个问题,您需要将值传递给javascript函数。您可以通过对代码进行以下更改来做到这一点 将javascript函数更改为:
function redirect(){
var a = document.getElementById("id").value;
alert(a);
}
并将重定向作为
function redirect(id){
alert(id); /* or any other processing you need */
}
产品名称:
产品价格:
此处需要什么值?唯一定义了id的元素是
元素,它没有任何值谢谢,非常感谢。它工作了,我做了你提到的改变,我在我的脚本中得到了价值。太棒了!以后尝试使用不引人注目的()JavaScript;-)
function redirect(id){
alert(id); /* or any other processing you need */
}
<table>
<tr>
<td> </td>
<td>
<a href="javascript:redirect(<%= id%>)" >
<%-- CHANGE MADE ABOVE -- %>
<img src=<%= s%> style="width:90px; height:90px;" />
</a>
</td>
<td>
<p>Product Name : <%= name %></p>
<p>Product Price : <%= list.get(i).getProdPrice() %></p>
</td>
</tr>
</table>