Scriptletへのテキストボックス値
-
29-10-2019 - |
質問
<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;
}
コメントを表示]をクリックするたびに、値が印刷されていません。 Scriptletに[場所にアクセスし、テキスト領域の値を印刷したいと思います。これはアクセスするための最良の方法ではないことを知っていますが、このようにアクセスする必要があります。誰かが私を助けることができますか?
解決
位置変数の値のダブル/シングル引用符を見逃しました。フォームを送信する必要がない場合は、ボタン入力要素を使用してください。
<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;
}
所属していません StackOverflow