I use .innerHTML
to add text in textarea
. But If I starting edit text in textarea
by myself script stops working.
Here it is:
var addPort = function (name) {
switch(name) {
case 'name1':
var code = "text1";
break
case 'name2':
var code = "text2";
break
case 'name3':
var code = "text3";
break
default:
break
}
document.getElementById("codeArea").innerHTML += code;
};
<textarea id="codeArea" name="codeAreaPost">abcdef</textarea>
<p> <button onclick="addPort()">addPort()</button>
its just replace innerHTML
by value property
document.getElementById("codeArea").value
not innerHTML