How to use javascript to set text area value in a form in IE

user570494 picture user570494 · Apr 8, 2011 · Viewed 36.8k times · Source

I can use this to set a text area (selectedtext) value in a form (submitquestion) if Firefox, but it fails in IE.

document.submitquestion.selectedtext.value = txt;

Answer

ysrb picture ysrb · Apr 8, 2011

This should work:

<textarea id="bla">from</textarea>
<script type="text/javascript">
document.getElementById("bla").value = "test";
</script>