Page 1 of 1

Textarea and innerHTML

Posted: Fri Apr 01, 2005 2:29 am
by Chris Corbyn

Code: Select all

<script>
function copyText() {
    document.getElementById('copyto').innerHTML = document.getElementById('testinput').innerHTML;
}
</script>
<textarea id=&quote;testinput&quote; onKeyup=&quote;copyText()&quote;></textarea>
<div id=&quote;copyto&quote;></div>
For some reason this won't work in NS/Moz - it's doesn't pick up text typed in by the user. IE does however. BUT if I put some text into the code itself, Moz/NS copy this text but still don't see the stuff a user types:

Code: Select all

<textarea id=&quote;testinput&quote; onKeyup=&quote;copyText()&quote;>Some text here</textarea>
:?

EDIT | OK - Using value as opposed to innerHTML works but innerHTML was actually quite handy here since it reads as entities. If anybody has a workaround it would be good - cheers :-)

Posted: Fri Apr 01, 2005 2:49 am
by Chris Corbyn
Actually, I'm just being stupid. Ignore me, I can mange just fine with escape(value) anyway.