Say, for example, the user enters 10 in the first screen. On the next screen, you can do something like,
$textboxes_number=$_POST['number']; //the number of textboxes the user wants
$textboxes_number=10; //say user enters 10 in the previous screen
echo "<form name=form method=post action=somepage.php>";
for($i=0;$i<$textboxes_number;$i++){
echo "<input type='text' name=txt$i>";
}
echo "<input type='submit' name='submit' value='submit'>";
echo "</form>";
This will generate 10 textboxes with different names.
Cheers,
Naveen
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
Have a hidden field to pass the number of textboxes. In the next page, use a for loop to get the values entered in those textboxes.
for($i=0;$<$number_of_textboxes;$i++){
$txtboxname=$txt.$i;
$textbox_value=$_POST[$txtboxname];
print $textbox_value;
}
:)
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
try it like this
for($i=0;$<$number_of_textboxes;$i++){
$txtboxname = $txt.$i;
$textbox_value .= $_POST[$txtboxname] ;
$textbox_value .= "
"; //one value per line
}
echo $textbox_value;
hope it works
rudevils
Junior Poster in Training
80 posts since Jan 2008
Reputation Points: 10
Solved Threads: 10
hi
i tried both the below codes.
it is displaying the text box id,but not the user input
if (isset($_REQUEST['Submit']))
{
echo $_SESSION[tboxes];
for($i=0;$i < $_SESSION[tboxes];$i++)
{
$txtboxname=$txt.$i;
echo $txtboxname;
$textbox_value=$_REQUEST[$txtboxname];
echo $textbox_value;
}
}
for($i=0;$i < $_SESSION[tboxes];$i++){
$txtboxname = $txt.$i;
echo $txtboxname;
$textbox_value .= $_REQUEST[$txtboxname] ;
$textbox_value .= "
"; //one value per line
echo $textbox_value;
}
}
hi, there's a mistake in my earlier code
here's the right one ( i've tried it)
first u must make a hidden field in your form for number of textbox
example "" (value automatically fill based on user request)
if($_POST[Submit]) { //if user submit your form
$textbox_value = ""; //initiate value for result
for($i=0;$i <$textbox_num ;$i++){
$txtboxname = "txt".$i; //no $ sign in txt
$textbox_value .= $_POST[$txtboxname]."
";
}
echo "value = $textbox_value"; //print result after "for" loop
}
hope u understand it :D
rudevils
Junior Poster in Training
80 posts since Jan 2008
Reputation Points: 10
Solved Threads: 10