<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var i =1;
function addkid(){
if(i<=3){
i++;
var div=document.createElement('div');
div.innerHTML="Child:<input type="text" name="child_1">
<input type="button" id="add_kid()" onclick="addkid()" value="+" />
<input type="button" value="-" onclick="removekid(this)">";
document.getElementById('kids').appendChild(div);
}
}
function removekid(div){
document.getElementById('kids'.removeChild(div.parentNode);
i--;
}
</script>
</head>
<body>
<form>
Name: <input type="text" name="name"><br/>
<div id="kids">
Child:<input type="text" name="child_1">
<input type="button" id="add_kid()" onclick="addkid()" value="+" />(limit 3)
</div>
Phone: <input type="text" name="phone"><br/>
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
This is my html code which has a JavaScript function to add a text box dynamically when the '+' button is clicked, but the program does not work giving an error:
(check5.php?name=&child_1=&phone=:10 Uncaught SyntaxError: Unexpected identifier)` in the JavaScript function part 1.
Please help me to solve this
div.innerHTML = ....)