Hi...
I want to add a text field inside a div(div with id "my_div") tag dynamically(By clicking "Add" button).
The code below shown is adding the new textfield after the submit button not inside the "my_div" div .
<html>
<head>
<script language="javascript">
function add()
{
var divTag = document.createElement("div");
divTag.id = "div";
//alert(divTag.id);
//divTag.setAttribute("align","center");
//divTag.style.margin = "0px auto";
divTag.className ="dynamicDiv";
divTag.innerHTML = "<input type='text' name='mytext[]' value='mytext'>";
document.f.appendChild(divTag);
}
</script>
</head>
<body>
<form name="f" id="f" action="homep.php" method="get">
<input type="button" value="Add" onClick="add()">
<div id="my_div" name="my_div">
</div>
<br>
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
I had given as following,
document.f.my_div.appendChild(divTag);
for adding textfield inside div.But it showing errors..
Any body knows this solution please help me...