/ Published in: JavaScript
URL: http://forums.digitalpoint.com/showthread.php?t=1057277
Expand |
Embed | Plain Text
<html> <head> <style> .foo { background: #ccc; font-weight: bold; margin: 2px; } </style> </head> <body> <input id="button" type="button" value="add input" /><br /><br /> <div id="inputs" style="width: 200px;"></div> <script type="text/javascript"> var target = document.getElementById("inputs"), count = 1, addInput = function() { var input = document.createElement("input"); input.setAttribute("name", "field"+count); input.setAttribute("id", "field"+count); input.setAttribute("value", "field"+count); input.setAttribute("size", 5); input.className = "foo"; target.appendChild(input); count++; }; document.getElementById("button").onclick = addInput; </script> </body> </html>
You need to login to post a comment.
