Need help on this one, I have this code where i intend to use, it adds a new textarea each time a button is clicked. How can i assign a unique element name for each textarea created?
Code:
<script type="text/javascript">
function addTextArea()
{
var newInput = document.createElement("textarea");
newInput.setAttribute("type", "text");
newInput.setAttribute('id','idName');
newInput.setAttribute('name','name');
newInput.setAttribute("cols", "50");
newInput.setAttribute("row", "30");
document.getElementById("divToAddTextBox").appendChild(newInput);
}
</script>
<body>
<form name ="reg" method="POST" action="sample_a.php">
<table><tr><td id="divToAddTextBox" width="400">
</td></tr>
<input type="button" onclick="addTextArea()" value="Click Here to Add Textbox" />
<input type="button" onclick="submit()" value="Click Here Submit" />
</table>
</body>
Comment