The value of the text field for the scriptlet
<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; }
Each time I click "View Comment", there is no value. I want to access a place in a scriptlet and print the value in a text area. I know that this is not the best way to access it, but I need to access it this way. Can someone help me?
+4
1 answer
You have lost double / single quotes for the value of the location variable. If you do not need to submit a form, just use the button input element.
<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; }
+2