javascript - textbox value to scriptlet - Stack Overflow

<form name="myForm" method="post" onsubmit="return getComment()"><

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742321710a4421946.html

相关推荐

  • javascript - textbox value to scriptlet - Stack Overflow

    <form name="myForm" method="post" onsubmit="return getComment()"><

    14小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信