admin管理员组

文章数量:1332352

    <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 badges
Add a ment  | 

1 Answer 1

Reset to default 2

You 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;
}

本文标签: javascripttextbox value to scriptletStack Overflow