Reputation: 13
I am doing online shoping webpage.i required to show textboxes based on input number By using onKeyPress Event.
Ex: textBooks Howmany
PHP Guid 3
Then create 3 textboxes with same name PHP Guid in bellow.
like
PHP Guid
PHP Guid
PHP Guid
Thanking you in Advance.
Upvotes: 0
Views: 4091
Reputation: 542
Hima
function duplicate() { var l=Number(document.getElementById('textbox name where u r entered')); for($i = 0; $i<l; $i++) { <input type=\’Text\' name=\'group'.$i.'\' id=\'Textbox'.$i.'\' value=\'' pass text box text here '\' >''</input>'; } }
this is javascript.
and babonk give you solution in php.
Upvotes: 0
Reputation:
<html>
<head>
<title>Dynamic Form</title>
<script language="javascript">
function changeIt(count)
{
var i;
for(i=0;i<count;i++)
{
my_div.innerHTML = my_div.innerHTML +"<br><input type='text' name='mytext'+ i>";
}
}
</script>
</head>
<body>
<form name="form" action="post" method="">
<input type="text" name="t1" onblur="changeIt(this.value)">
<div id="my_div"></div>
</form>
</body>
Upvotes: 2
Reputation: 3785
try this
if input number is 5
for($j = 1; $j <= 5; $j++) {
echo "<input type="text" name="textfield[]">";
}
Upvotes: 1