4
<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中找到並在文本區域中打印值。 我知道這不是訪問它的最佳方式,但我需要以這種方式訪問它。 任何人都可以幫助我嗎?textbox value to scriptlet
非常感謝。 – joanna
順便說一句,它的工作原理,但我總是得到一個null值在評論區。 – joanna
使用瀏覽器上下文菜單中的「查看源代碼」選項查看頁面的源代碼。並檢查打印的值是什麼值作爲var location =「?」的值; 。「定位」Java變量是空的,我想。 (並注意我將輸入按鈕的事件句柄更正爲「onclick」。) –