0
<form>
no of textboxes needed to generate dynamically<input type="text" name="tboxes" size="50">
<input type="Submit" name="Submit" value="Submit">
</form>
<?php
$tboxes=$_REQUEST['tboxes'];

for ($i=1;$i<=$tboxes;$i++)
{  
 print "<input type='text' name=txt$i>";
}
 print "<input type='submit' name='submit' value='submit'>";
?>

please do tell me how to get the values entered in a textboxes,i want to know whether i can use array .....if so then please do tell me

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by lydia21
0

Well you don't really need to use PHP for that, that is some very simple JavaScript

function addBoxes(numBoxes, parent)
{
   for(i=0;i<numBoxes;i++)
   {
      $tmpbox = document.createElement('input');
      $tmpbox.type = "text";
      $tmpbox.id = "txt"+i;
      parent.appendChild($tmpBox);
   }
}

Then in the page just put

<form>
no of textboxes needed to generate dynamically
<input type="text" id="numboxes" name="tboxes" size="50">
<input type="button" name="create" value="Create Inputs" 
    onclick="addBoxes(document.getElementById('numboxes').value, this.parentNode);">
</form>
0

ya tat helped me in generating textboxes with different name but how to get the values from the textboxes which is generated

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.