Posted by Adam Plocher on 09/27/01 11:37
Johnny, I'm not sure if I understand you correctly, but you can try
this:
note.. I didn't test this code, but I think this is what you're looking
for.
<?PHP
if ($_POST['Submit'])
{
$field = $_POST['field'];
for ($i = 0; $i < count($field); $i++)
{
// echo all results
echo $field[$i] ."<br />\n";
}
}
else
{
// $fc = field count
$fc = $_POST['fc'];
if (!is_numeric($fc) || $fc == "")
{
// if fc isn't set - default it to 1
$fc = 1;
}
if ($_POST['AddField'])
{
// if AddField button was clicked - increment $fc
$fc++;
}
?>
<form action="<?PHP echo $_SERVER['PHP_SELF'];?>" method="post">
<?PHP
for ($i = 1; $i <= $fc; $i++)
{
echo "<input type=\"text\" name=\"field[". $i ."]\"
value=\"\"><br />\n";
}
?>
<input type="submit" name="AddField" value="add more fields">
<input type="submit" name="Submit" value="submit">
<input type="hidden" name="fc" value="<?PHP echo $i;?>">
</form>
<?PHP
}
?>
Navigation:
[Reply to this message]
|