Hello,
I am trying to have the user input preview as it is being typed like in this webpage:
[url]http://microformats.org/code/hcard/creator
However, when I try it, the preview keeps getting appended after each character is inputed as seen here:
[url]http://ia311216.us.archive.org/2/items/Hlisting.01a/hlisting.html
Below is the code I used. I’m fairly new to javascript programming. Am I on the right track? Any suggestions would be appreciated. Thanks!
[CODE]
<html>
<head>
<script type=”text/javascript”>
function preview()
{
var preview = document.createElement(“div”);
preview.setAttribute(“id”, “preview”);
var name = document.createTextNode(document.getElementById(“name”).value);
preview.appendChild(name);
document.getElementById(“wrapper”).appendChild(preview);
}
</script>
</head>
<body>
<div id=”wrapper”>
<div>
<p><input id=”name” type=”text” onKeyUp=”preview();” /></p>
</div>
</div>
</body>
</html>