简体   繁体   English

通过 JSP 在脚本上获取 textarea 编辑的文本

[英]Get textarea edited text on script by JSP

I need to get the text a user enters in a textarea, in a script from JSP.我需要从 JSP 的脚本中获取用户在 textarea 中输入的文本。 I tried this code but get null value:我尝试了这段代码,但得到了 null 值:

<label for="userText"></label>
<textarea name="userText" id="userText">text edited by the user</textarea>
<button onclick="myFunction()">Ok</button>

function myFunction() {
    <%System.out.print(request.getParameter("userText"));%>
}

I can i get it?我能得到吗?

You will have to use Java Script for this您将不得不为此使用 Java 脚本

var message = $('textarea#userText').val();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM