Date: 07/25/02
- Next message: Johnson, Kirk: "RE: [PHP] New way to make select boxes auto select"
- Previous message: Andrew Hill: "RE: [PHP] Where do I specify a DSN? v0.2"
- In reply to: Nathan Cook: "[PHP] New way to make select boxes auto select"
- Next in thread: Johnson, Kirk: "RE: [PHP] New way to make select boxes auto select"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Interesting technique. Depending on your error_reporting levels, you may get
a bunch of undefined variable warnings, though.
I usually use a config file with arrays for my select boxes. Something like
$_CONF['Something'] = array("This","That","And","Something");
Then just create a function like conf_select($key,$selected); where you pass
the $_CONF variable key that you want the select box to be made of and the
default value.
---John Holmes...
----- Original Message -----
From: "Nathan Cook" <ncook <email protected>>
To: "Php List" <php-general <email protected>>
Cc: "David Chase" <dchase <email protected>>
Sent: Thursday, July 25, 2002 12:33 PM
Subject: [PHP] New way to make select boxes auto select
> You may already be doing it like this, but I think I found a new way to
> make select boxes auto-select (what data they put in) a lot easier. All
you
> have to do is put a variable in each select tag that is equal to the value
> of the select option i.e.: <option value=teacher $teacher> -- then all you
> have to do is base the variable on that <select name=interest> $$interest
=
> "selected"; quick and easy with out having to loop through an if elseif
> statement. Let me know if you like that method or have any objections.
>
> Full example below.
>
> print("<select name=interest>\n");
> // creates a variable with a name based on
> // the value of interest with a value of "selected"
> $$interest = "selected";
> print("<option value=>- Select One -</option>\n");
> print("<option value=teacher $teacher>Teacher</option>\n");
> print("<option value=lego $lego>Lego Enthusiast</option>\n");
> print("<option value=student $student>Student</option>\n");
> print("<option value=homeschool $homeschool>Homeschool
Parent</option>\n");
> print("<option value=browsing $browsing>Browsing</option>\n");
> print("<option value=afterschool $afterschool>Afterschool</option>\n");
> print("<option value=bgca $bgca>Boys & Girls Club</option>\n");
> print("<option value=ymca $ymva>YMCA</option>\n");
> print("</select> \n");
>
> [ Nathan Cook | ncook <email protected> ]
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Johnson, Kirk: "RE: [PHP] New way to make select boxes auto select"
- Previous message: Andrew Hill: "RE: [PHP] Where do I specify a DSN? v0.2"
- In reply to: Nathan Cook: "[PHP] New way to make select boxes auto select"
- Next in thread: Johnson, Kirk: "RE: [PHP] New way to make select boxes auto select"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

