简体   繁体   English

将文本从HTML div发送到HTML textarea

[英]Send text from a HTML div to a HTML textarea

I am trying to send text from ASP server to a client side DIV and then to a client side textarea. 我正在尝试将文本从ASP服务器发送到客户端DIV,然后发送到客户端textarea。

I cannot send directly from ASP server side to the client side textarea, because if I do that the server crashes/lose server connection. 我不能直接从ASP服务器端发送到客户端textarea,因为如果我这样做,服务器崩溃/丢失服务器连接。

<script type="text/javascript">
    function FromJavaScriptToASP() {
        document.getElementById('<%= JavascriptToAspButton.ClientID %>').click();
        var output = document.getElementById('<%= textdiv.ClientID%>');
        var textarea = document.getElementById("MainTextBox");
        textarea.value = output.value;
    }
</script>

When I use this javascript I get a error saying: "Microsoft JScript runtime error: Object required" 当我使用这个javascript时,我收到一条错误消息:“Microsoft JScript运行时错误:需要对象”

How can I send text from a HTML div to a HTML textarea? 如何将HTML div中的文本发送到HTML textarea?

div elements do not have value. div元素没有价值。 You can get their text through textContent or innerText , or various other ways if you want to consider child elements too for example. 如果您想要考虑子元素,可以通过textContentinnerText或其他各种方式获取文本。

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

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