Re: Newbie help: Need code snippet ASAP
| From: | Szii | Date: | Sun, 04 Jun 2000 06:06:29 +0000 |
| Subject: | Re: Newbie help: Need code snippet ASAP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-965@lists.php.net to get a copy of this message | ||
Create a session, register the variables (1 per field) and do
if (isset($f_myfieldLine1))
{
print "<input type=text value=\"$f_myfieldLine1\">";
}
else
{
print "<input type=text value=\"To be filled in\">";
}
True, you have to do it for each field in the form but with a series of
session
items you don't have to keep resubmitting all those HIDDEN fields. =)
-Szii
Peace, love, and code.
At 12:27 PM 6/2/00 -0500, Matt McClanahan wrote:
>On Fri, 2 Jun 2000, Dion Vansevenant wrote:
>
>> I apologize if this has been asked before, but I am new to PHP and have a
>> rather short deadline for a page that needs to be built, so I hope someone
>> will be able to help me.
>>
>> I am working on a form that a user here has to fill out containing
variables
>> lines of information. This form, when submitted will be emailed to a client
>> with a return address for someone else in our company. Don't worry, it's
>> perfectly legit and not spam.
>
><snip>
>
>> What I need to do is enable the person filling the form to add as many of
>> Lines 1 to 3 as they need, while still retaining any information already
>> entered. So the form could look like this:
>
>This sort of dynamic content isn't easy to do with web pages. One option
>I might suggest would be to provide a box where the user can enter how
>many groups of Lines 1 to 3 they plan on entering. That way, your form
>can generate the desired number of lines. It's not a very elegant
>solution from a UI standpoint, of course. I don't know if there's a
>better way with DHTML or somesuch, but it'd surprise me. :)
>
>Anyway, the code for that suggestion would simply be a for loop that spits
>out the number of for fields desired. $fieldCount reflects how many
>groupings of Lines 1 to 3 they want.
>
>for( $i = 0; $i < $fieldCount; $i++ )
>{ ?>
> Line1: <input type="text" name="line1[]"><br>
> Line2: <input type="text" name="line2[]"><br>
> Line3: <input type="text" name="line3[]"><br>
><? }
>
>Which will make three arrays of fields. So your first grouping would be
>$line1[0], $line2[0], $line3[0], the second $line1[1], $line2[1],
>$line3[1], and so on.
>
>HTH,
>Matt
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
>