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

I can use this to set the value of the text area (selectedtext) on the form (submitquestion) if Firefox, but this does not work in IE.

document.submitquestion.selectedtext.value = txt;

+5
source share
4 answers

This should work:

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

Try the following:

document.forms['submitquestion'].elements['selectedtext'].value = txt;

Assuming you have:

<form name='submitquestion'>
    <textarea name='selectedtext'></textarea>
</form>
+3
source

JQuery, .

$('#selectedtext').val('whatever');
+1

javascript,

document.getElementById("myTextarea").value = txt;
0

All Articles