<form name="myForm" method="post" onsubmit="return getComment()">
<textarea id="commentarea"></textarea>
<input type="text" name="locate" value="<%=rs.getString("location")%>">
<input type="submit" value="View Comment">
</form>
function getComment(){
<% String locate=request.getParameter("locate"); %>
var location = <%= locate%>;
document.getElementById('commentarea').value=location;
return false;
}每次我点击View Comment,都没有打印出任何值。我想访问位于scriptlet中的位置,并在文本区域中打印值。我知道这不是访问它的最佳方式,但我需要以这种方式访问它。有谁可以帮我?
发布于 2011-12-08 00:22:09
位置变量的值缺少双引号/单引号。如果不需要提交表单,只需使用按钮输入元素。
<form name="myForm" method="post">
<textarea id="commentarea"></textarea>
<input type="text" name="locate" value="<%=rs.getString("location")%>">
<input type="button" value="View Comment" onclick="getComment()">
</form>
function getComment(){
<% String locate=request.getParameter("locate"); %>
var location = "<%= locate%>";
document.getElementById('commentarea').value = location;
}https://stackoverflow.com/questions/8418615
复制相似问题