简体   繁体   中英

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.

I cannot send directly from ASP server side to the client side textarea, because if I do that the server crashes/lose server connection.

<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"

How can I send text from a HTML div to a HTML textarea?

div elements do not have value. You can get their text through textContent or innerText , or various other ways if you want to consider child elements too for example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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