Jump to content

What Am I Doing Wrong?


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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...