| | |
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 |
301 advanced apache api array autosuggest basics beginner broken cakephp class cms code combobox compression cron curl data database date datepart display dropdownlist dynamic email eregi error execution file files folder form forms function functions google head href htaccess html httppost if...loop image include includingmysecondfileinthechain ip javascript job joomla jquery js key library limit link login md5 menu mlm multiple mysql mysql_real_escape_string oop password paypal pdf pdfdownload php phpvotingscript problem procedure query random screen script search searchbox server session sessions smarty source space sql stored system table traffic tutorial unicode upload url variable video volume votedown web website youtube zend






