943,589 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1267
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Jan 14th, 2008
0

help

Expand Post »
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
Reputation Points: 19
Solved Threads: 5
Junior Poster
lydia21 is offline Offline
183 posts
since Nov 2007
Jan 14th, 2008
0

Re: help

Say, for example, the user enters 10 in the first screen. On the next screen, you can do something like,
php Syntax (Toggle Plain Text)
  1. $textboxes_number=$_POST['number']; //the number of textboxes the user wants
  2. $textboxes_number=10; //say user enters 10 in the previous screen
  3. echo "<form name=form method=post action=somepage.php>";
  4. for($i=0;$i<$textboxes_number;$i++){
  5. echo "<input type='text' name=txt$i>";
  6. }
  7.  
  8. echo "<input type='submit' name='submit' value='submit'>";
  9. echo "</form>";

This will generate 10 textboxes with different names.

Cheers,
Naveen
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Jan 14th, 2008
0

Re: help

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.
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007
Jan 15th, 2008
0

Re: help

thanks it worked..........
Quote ...
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>
next page to process further(test3.php)

Quote ...
<form>
<?php
if (isset($_REQUEST['Submit']))
{
for ($i = 0; $i < 5; $i++)
{
$i=$_REQUEST['i']:
echo $i;
}
}
}
?>
</form>
please do tell me how to get the values entered in the text boxes to the next page
Reputation Points: 19
Solved Threads: 5
Junior Poster
lydia21 is offline Offline
183 posts
since Nov 2007
Jan 15th, 2008
0

Re: help

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)
  1. for($i=0;$<$number_of_textboxes;$i++){
  2. $txtboxname=$txt.$i;
  3. $textbox_value=$_POST[$txtboxname];
  4. print $textbox_value;
  5. }

Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Jan 15th, 2008
0

Re: help

textbox value is not getting printed
Reputation Points: 19
Solved Threads: 5
Junior Poster
lydia21 is offline Offline
183 posts
since Nov 2007
Jan 16th, 2008
0

Re: help

code ?
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Jan 16th, 2008
0

Re: help

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
Reputation Points: 10
Solved Threads: 10
Junior Poster in Training
rudevils is offline Offline
80 posts
since Jan 2008
Jan 16th, 2008
0

Re: help

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


}
Reputation Points: 3
Solved Threads: 2
Junior Poster
kings is offline Offline
107 posts
since Nov 2007
Jan 16th, 2008
0

Re: help

Click to Expand / Collapse  Quote originally posted by kings ...
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;
}


}
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 < $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
Reputation Points: 10
Solved Threads: 10
Junior Poster in Training
rudevils is offline Offline
80 posts
since Jan 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Creation of Hotmail Contacts Importer
Next Thread in PHP Forum Timeline: Need help NEWSLETTER





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC