Hello. I need some kind of javascript I believe so that when I typed text into a form field, the text also shows up on the other side of the page under a header as plain text. Without a refresh needed obviously or without needing to submit form. If you don't understand what I mean I'll try to explain better Thanks, +REP to helpers.
var obj = document.getElementById("TextAreaId"); obj.onChange = function (){ document.getElementById("NewContentAreaId").innerHTML = obj.value; } Code (markup): that may work
Thanks but I've never really used javascript before so how would I go about using it? I tried: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <script> var obj = document.getElementById("textarea"); obj.onChange = function (){ document.getElementById("div").innerHTML = obj.value; } </script> </head> <body> <textarea name="textarea" cols="7" rows="7" id="textarea"></textarea> <div id="div"></div> </body> </html> Code (markup): But that didn't work
here, you can play with this <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <textarea name="textarea" cols="7" rows="7" id="textarea" onchange="document.getElementById('div').innerHTML=this.value">asdffewf2</textarea> <div id="div">asdf</div> </body> </html> Code (markup):