| | |
help
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
Say, for example, the user enters 10 in the first screen. On the next screen, you can do something like,
This will generate 10 textboxes with different names.
Cheers,
Naveen
php Syntax (Toggle Plain Text)
$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
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Posts: 183
Reputation:
Solved Threads: 5
thanks it worked..........
next page to process further(test3.php)
please do tell me how to get the values entered in the text boxes to the next page
•
•
•
•
test3.php
<form method="post" action="test3.php">
<?php
$tboxes=$_REQUEST['tboxes'];
echo $tboxes;
if (isset($_REQUEST['Submit']))
{
for ($i = 0; $i < $tboxes; $i++)
{
print "<input type='text' name=txt$i>";
}
print "<input type='Submit' name='Submit' value='Submit'>";
}
?>
</form>
•
•
•
•
<form>
<?php
if (isset($_REQUEST['Submit']))
{
for ($i = 0; $i < 5; $i++)
{
$i=$_REQUEST['i']:
echo $i;
}
}
}
?>
</form>
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.
php Syntax (Toggle Plain Text)
for($i=0;$<$number_of_textboxes;$i++){ $txtboxname=$txt.$i; $textbox_value=$_POST[$txtboxname]; print $textbox_value; }
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Jan 2008
Posts: 79
Reputation:
Solved Threads: 9
try it like this
for($i=0;$<$number_of_textboxes;$i++){
$txtboxname = $txt.$i;
$textbox_value .= $_POST[$txtboxname] ;
$textbox_value .= "<br>"; //one value per line
}
echo $textbox_value;
hope it works
for($i=0;$<$number_of_textboxes;$i++){
$txtboxname = $txt.$i;
$textbox_value .= $_POST[$txtboxname] ;
$textbox_value .= "<br>"; //one value per line
}
echo $textbox_value;
hope it works
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 .= "<br>"; //one value per line
echo $textbox_value;
}
}
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 .= "<br>"; //one value per line
echo $textbox_value;
}
}
•
•
Join Date: Jan 2008
Posts: 79
Reputation:
Solved Threads: 9
•
•
•
•
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 .= "<br>"; //one value per line
echo $textbox_value;
}
}
here's the right one ( i've tried it)
first u must make a hidden field in your form for number of textbox
example "<input name="textbox_num" type="hidden" value="10">" (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]."<br>";
}
echo "value = $textbox_value"; //print result after "for" loop
}
hope u understand it
![]() |
Other Threads in the PHP Forum
- Previous Thread: Creation of Hotmail Contacts Importer
- Next Thread: Need help NEWSLETTER
| Thread Tools | Search this Thread |
.htaccess ajax apache api array back basic beginner binary broken cakephp checkbox class cms code computing cron curl customizableitems database date delete display dynamic echo email error file files filter folder form forms function functions gc_maxlifetime google host href htaccess html image include insert integration ip java javascript joomla limit link login loop mail memmory memory menu mlm mod_rewrite multiple mysql navigation oop parsing paypal pdf php problem query radio random recursion regex remote script search server sessions sms snippet soap source space sql syntax system table thesishelp trouble tutorial update upload url validation validator variable video web xml youtube






