input - Change a Text with Javascript -


i want chance text javascript use following code:

<!doctype html public "-//w3c//dtd html 4.01 transitional//en"> <html><head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>test</title> <script type="text/javascript"> var neu = document.getelementbyid("thema")[0].value; function aendern () {   document.all.meinabsatz.innerhtml = neu; } </script> </head><body> <p id="meinabsatz">text</p> <input id="thema" type="text" value="test theme" /> <a href="javascript:aendern()">chance theme</a> </body> </html> 

if click on "chance theme" "text" chance "undefined"

method getelementbyid() returns single element, not set of elements. there no need in applying [0] it. should put neu initialization inside aendern() function:

function aendern() {     var neu = document.getelementbyid("thema").value;     document.all.meinabsatz.innerhtml = neu; } 

demo: http://jsfiddle.net/rqgmb/


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -