Page 1 of 1

Textbox looping

Posted: Thu Mar 25, 2004 10:23 pm
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?

Re: Textbox looping

Posted: Thu Mar 25, 2004 10:36 pm
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.