I have written a basic Greasemonkey script which passes an output out to a textarea, like this:
var obj = document.getElementById("comment").innerHTML = "\n" + "Note:" + "\n" + "\n" + output_string;
It works like a charm, if you change the value from the source, it will update the textarea. However, as soon as you write anything yourself inside the textarea and select a value, it will not overwrite what you written inside the textarea. And you need to refresh the page entirely to be able to use the function again. Why is that?
The
textarea‘svalueattribute is set as soon as you type something into it. This overrides anyinnerHTMLvalue.You should be using the
valueattribute to set the contents of input elements liketextarea.Try this instead: