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;
<textarea> does not support the value attribute.
The HTMLTextAreaElement interface provides special properties and methods for manipulating the layout and presentation of <textarea> elements.
Use the <textarea> tag to show a text area. The HTML <textarea> tag is used within a form to declare a textarea element - a control that allows the user to input text over multiple rows. Specifies that on page load the text area should automatically get focus.
This should work:
<textarea id="bla">from</textarea>
<script type="text/javascript">
document.getElementById("bla").value = "test";
</script>
Try this:
document.forms['submitquestion'].elements['selectedtext'].value = txt;
Assuming you have:
<form name='submitquestion'>
<textarea name='selectedtext'></textarea>
</form>
I recommend using JQuery, it works with all browsers.
$('#selectedtext').val('whatever');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With