| | |
help
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: 80
Reputation:
Solved Threads: 10
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: 80
Reputation:
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 .= "<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
Views: 1150 | Replies: 10
| Thread Tools | Search this Thread |
Tag cloud for PHP
access ajax apache array beginner box broken buttons cakephp check checkbox class cms code cookies database date directory display download dropdown drupal dynamic echo email error file files folder form forms function functions header hosting href htaccess html image images include insert ip java javascript joomla jquery limit link list login loop mail menu methods mlm mod_rewrite multiple mysql order parse password paypal php problem query radio random redirect regex remote results script search security select server session sessions shopping soap sort sorting source sql string system table unicode update upload url user validation variable video web website wordpress xml






