
Here is the HTML code to create text boxes dynamically. It works properly in IE but not in fire fox and chrome. how to make this to work in all browsers.
And also how to validate the text boxes created dynamically.
<html>
<head>
<title>Multiple Text area Validation</title>
<script>
function addInputBox() {
var ni = document.getElementById('myDiv');
var ni1=document.getElementById('myDiv1');
var numi = document.myForm.inputboxlength;
var numi1=document.myForm.inputboxlength;
var num = parseInt(numi.value) +1;
var num1=parseInt(numi1.value)+1;
numi.value = num;
numi1.value=num1;
var newdiv = document.createElement('div');
var newdiv1=document.createElement('div');
newdiv.innerHTML = "<input type=\"text\" name=\"txt"+num +"\" />" ;
newdiv1.innerHTML="<input type=\"text\" name=\"txt1"+num1+"\"/>";
ni.appendChild(newdiv);
ni1.appendChild(newdiv1);
}
function reset()
{
var numi = document.myForm.inputboxlength;
numi.value=0;
}
</script>
</head>
<body onload="reset()">
<form name="myForm" action="result.jsp" >
<p><input type='button' onclick='addInputBox()' value='Add'/></p>
<input type="hidden" name="inputboxlength" value="0" />
<!--<div id="myDiv"><div id="myDiv1"></div> </div> -->
<div id="mydiv"><div id="mydiv1"></div></div>
<input type="submit" value="Submit" >
</form>
</body>
</html>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.