Jump to content

What Am I Doing Wrong?


solar

Recommended Posts

<html><body><form><input id="inp" type="text" /><input type="button" value="button" onclick="funct()" /></form><div id="dv">abc</div><script type="text/javascript">function funct() {var x = document.getElementById('inp').value;var t = x.length;for (i=0;i<t;i++) {z = document.getElementById('dv').innerHTTML;document.getElementById('dv').innerHTTML = z.concat(x.charAt(i));}}</script></body></html>

i want to concatenate input text to <div>'s content one character at a time.so if i type defgh in the text field, after pressing the button <div> should show abcdefgh, right?but it's not working

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...