Textbox looping

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
S_henry
Forum Contributor
Posts: 148
Joined: Sun Jan 25, 2004 10:25 pm
Location: M'sia

Textbox looping

Post by S_henry »

I want to make like this. On my form, I just have 1 textbox for the 1st time. After this textbox has filled, when I press 'Enter', this form will submit and return back to this form. After return, 1 more textbox(empty) will be added onto this form and the previous textbox will display the value I've entered before submit. This process will continue so on. This mean, if I've press 'Enter' 10 times, this form should have 11 textboxes on it with the last textbox is empty. Anybody have the idea?
aleigh
Forum Commoner
Posts: 26
Joined: Thu Mar 25, 2004 11:06 am
Location: Midwestern United States
Contact:

Re: Textbox looping

Post by aleigh »

S_henry wrote:I want to make like this. On my form, I just have 1 textbox for the 1st time. After this textbox has filled, when I press 'Enter', this form will submit and return back to this form. After return, 1 more textbox(empty) will be added onto this form and the previous textbox will display the value I've entered before submit. This process will continue so on. This mean, if I've press 'Enter' 10 times, this form should have 11 textboxes on it with the last textbox is empty. Anybody have the idea?
<?php

if(!$_POST['count'])
$count=1;
else
$count=$_POST['count'];

print '<FORM ACTION="test.php" METHOD=POST>
<INPUT TYPE="HIDDEN" NAME="count" VALUE="'.($count+1).'">';

for($i=0;$i<$count;$i++)
print '<INPUT NAME="'.$i.'" VALUE="'.$_POST["$i"].'"><P>';

print '<INPUT TYPE="SUBMIT"></FORM>';

?>

I hope I, er, you get a good grade.
Post Reply