0

hi,
i want to develop a application....
where the user can enter the no of text boxes he wants..in the next page based on the user input it should disply the text boxes with different id

5
Contributors
10
Replies
11
Views
9 Years
Discussion Span
Last Post by lydia21
0

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

0

use javascript,
when the user enters data into first textbox, add there automatically another textbox n name it text02, keep this process and on post just catch the data. thats all.

0

thanks it worked..........

test3.php
<form method="post" action="test3.php">
<?php
$tboxes=$_REQUEST;
echo $tboxes;
if (isset($_REQUEST))
{
for ($i = 0; $i < $tboxes; $i++)
{
print "<input type='text' name=txt$i>";
}
print "<input type='Submit' name='Submit' value='Submit'>";
}
?>
</form>

next page to process further(test3.php)

<form>
<?php
if (isset($_REQUEST))
{
for ($i = 0; $i < 5; $i++)
{
$i=$_REQUEST:
echo $i;
}
}
}
?>
</form>

please do tell me how to get the values entered in the text boxes to the next page

0

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;
}

:)

0

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

0

hi
i tried both the below codes.
it is displaying the text box id,but not the user input

if (isset($_REQUEST))
{
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;
}


}

0

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;
}


}

end quote.

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 "<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 < [COLOR="Red"]$textbox_num[/COLOR] ;$i++){
            $txtboxname = [COLOR="Red"]"txt".$i;[/COLOR] //no $ sign in txt
            $textbox_value .= $_POST[$txtboxname]."<br>";
        }
    echo "value = $textbox_value"; //print result after "for" loop
}

hope u understand it :D

Edited by mike_2000_17: Fixed formatting

This question has already been answered. 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.