首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >scriptlet的textbox值

scriptlet的textbox值
EN

Stack Overflow用户
提问于 2011-12-08 00:17:47
回答 1查看 20K关注 0票数 4
代码语言:javascript
复制
    <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;
    }

每次我点击View Comment,都没有打印出任何值。我想访问位于scriptlet中的位置,并在文本区域中打印值。我知道这不是访问它的最佳方式,但我需要以这种方式访问它。有谁可以帮我?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-12-08 00:22:09

位置变量的值缺少双引号/单引号。如果不需要提交表单,只需使用按钮输入元素。

代码语言:javascript
复制
<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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8418615

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档