JavaScript gets TextArea input via .value or .innerHTML?

Is it possible to get the value of a textarea element in JavaScript using myTextArea.value or using myTextArea.innerHTML ?

Thank.

+43
javascript innerhtml textarea
Mar 15 2018-11-15T00:
source share
5 answers

You must use .value

 myTextArea.value 
+73
Mar 15 2018-11-15T00:
source share

For div and span, you can use innerHTML, but to use the value of textarea. See the example below.

 <script language="javascript/text"> document.getElementById("spanText").innerHTML ="text"; document.getElementById("divText").innerHTML ="text"; document.getElementById("textArea").value ="text"; </script> <span id="spanText"></span> <div id="divText"></div> <textarea id="textArea"></textArea> 
+6
Feb 11 '14 at 19:56
source share

Do not use innerHTML value, for example. document.getElementById (name) .value

+1
Oct 21 '17 at 21:41
source share

I don’t know if there is a wrong post here (sorry if that is the case) but I am working correctly. there are 64 of them on the application, see here: http://www.megapeng.com/dm64/dm64.html this will be an application for ipad and android, since users must be offline to use it. now I would like to have aerea text that collects all these “source text results” in order to have an overview. best will be specified (line break). (this is an audio mixer script for events)

 <script type="text/javascript"> <!-- var arrURLs = ["", "BD IN", "BD OUT", "SN TOP", function changeInput(objSel, strName){ objSel.form.elements[strName].value = arrURLs[objSel.selectedIndex]; } //--> </script> <form method="post" onSubmit="return false;"> <input class="track"type="text" name="txtOut" value="" /tabindex=3><p> <select class="trac" onChange="changeInput(this, 'txtOut');"";> <option value="t1">SELECT</option> <option value="t2">BDI N</option> <option value="t3">BD OUT</option> <option value="t4">SN TOP</option> 
0
May 14 '17 at 12:09
source share

The answer depends on your situation.

I personally would use .value as what other forms provide. It’s easier to be in the habit of doing it this way.

-one
Mar 15 '11 at 15:45
source share



All Articles