Re: Sticky Forms
| From: | rip | Date: | Sat, 21 Oct 2000 12:34:04 +0000 |
| Subject: | Re: Sticky Forms | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-21544@lists.php.net to get a copy of this message | ||
I like this method:
<?
function pr_states($state = "") {
$states = array(" "=>"
","AL"=>"Alabama","AK"=>"Alaska","AR"=>"Arkansas","AZ"=>"Arizona","CA"=>"Cal
ifornia","CO"=>"Colorado","CT"=>"Connecticut","DE"=>"Delaware","FL"=>"Florid
a","GA"=>"Georgia","HI"=>"Hawaii","ID"=>"Idaho","IL"=>"Illinois","IN"=>"Indi
ana","IA"=>"Iowa","KS"=>"Kansas","KY"=>"Kentucky","LA"=>"Louisiana","ME"=>"M
aine","MD"=>"Maryland","MA"=>"Massachusetts","MI"=>"Michigan","MN"=>"Minneso
ta","MS"=>"Mississippi","MO"=>"Missouri","MT"=>"Montana","NE"=>"Nebraska","N
V"=>"Nevada","NH"=>"New
Hampshire","NJ"=>"New Jersey","NM"=>"New
Mexico","NY"=>"New York","NC"=>"North
Carolina","ND"=>"North
Dakota","OH"=>"Ohio","OK"=>"Oklahoma","OR"=>"Oregon","PA"=>"Pennsylvania","R
I"=>"Rhode Island","SC"=>"South
Carolina","SD"=>"South
Dakota","TN"=>"Tennessee","TX"=>"Texas","UT"=>"Utah","VT"=>"Vermont","VA"=>"
Virginia","WA"=>"Washington","DC"=>"Washington,
DC","WV"=>"West
Virginia","WI"=>"Wisconsin","WY"=>"Wyoming");
while (list($key,$val) = each($states)) {
$selected = ($key==$state)?" selected":"";
$options .= "\t\t\t\t\t<option
value=\"$key\"$selected>$val</option>\n";
}
echo $options;
}
?>
In the html:
<td nowrap class=spacer9>State:</td>
<td>
<select name="state">
<? pr_state($state) ?>
</select>
</td>
or
<?
function pr_prefered_contact($prefered_contact = "") {
$prefered_contacts = array("Telephone","Postal
Mail","Email","Fax");
while (list($key,$val) = each($prefered_contacts)) {
$selected = ($val==$prefered_contact)?" selected":"";
$options .= "\t\t\t\t\t<option$selected>$val</option>\n";
}
echo $options;
}
?>
In the html:
<td nowrap class=spacer9>Prefered Contact:</td>
<td>
<select name="prefered_contact">
<? pr_prefered_contact($prefered_contact) ?>
</select>
</td>
?>
At 08:47 PM 10/20/00 -0700, you wrote:
>Steve,
>
>I ended up making a <select> sticky this way. It's crass but it works. Let me
>now if you know of a more elegant solution.
>
>Company:
><select name="selvar[company]">
> <option value="%" <?php if ($selvar[company] == "%") { echo
"selected";
>} ?> > IBM & Verizon
> <option value="IBM" <?php if ($selvar[company] == "IBM") { echo
"selected";
>} ?> > IBM
> <option value="GTE" <?php if ($selvar[company] == "GTE") { echo
"selected";
>} ?> > Verizon
></select>
>
>
>Steve Lawson wrote:
>
>> just echo the variables into the correct fields.
>>
>> <INPUT TYPE="text" NAME="f_msg" VALUE="<?php echo $f_msg;
>> ?>">
>>
>> When the page is generated the field will be blank because $f_msg will be
>> undefined. However, once you submit this page it will place the value back
>> into the field.
>>
>> SL.
>>
>> ----- Original Message -----
>> From: "Tim Sawyer" <tsawyer@socal.rr.com>
>> To: "PHP-GENERAL" <php-general@lists.php.net>
>> Sent: Friday, October 20, 2000 7:24 PM
>> Subject: [PHP] Sticky Forms
>>
>> > How do I make forms "sticky" like CGI.pm does? That is, I want a
>> > selection form element (or text, or whatever) to have the keep it's
>> > value when I press back or call the form itself. I'm brand new to PHP
>> > but I've been using CGI.pm for a while. Thanks for hehping me get
>> > started. Spent a couple of hours with the docks but can't find if PHP
>> > can do this.
>> >
>> > --
>> > Tim Sawyer
>> > :wq
>> >
>> >
>> >
>> > --
>> > 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
>> >
>
>--
>Tim Sawyer
>:wq
>
>