<form name="myForm" method="post" onsubmit="return getComment()">
<textarea id="mentarea"></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('mentarea').value=location;
return false;
}
Everytime i click View Comment, there's no value printed. I want to access locate in the scriptlet and print the value in the text area. I know this is not the best way to access it, but i need to access it in this way. Can anyone help me?
<form name="myForm" method="post" onsubmit="return getComment()">
<textarea id="mentarea"></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('mentarea').value=location;
return false;
}
Everytime i click View Comment, there's no value printed. I want to access locate in the scriptlet and print the value in the text area. I know this is not the best way to access it, but i need to access it in this way. Can anyone help me?
Share Improve this question asked Dec 7, 2011 at 16:17 joannajoanna 1171 gold badge4 silver badges12 bronze badges1 Answer
Reset to default 2You have missed double/single quotes for the value of the location variable. If you don't need to submit the form, just use a button input element.
<form name="myForm" method="post">
<textarea id="mentarea"></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('mentarea').value = location;
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742321710a4421946.html
评论列表(0条)