Re: New way to make select boxes auto select
| From: | Alexander Kuznetsov | Date: | Fri, 26 Jul 2002 07:29:12 +0000 |
| Subject: | Re: New way to make select boxes auto select | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-109682@lists.php.net to get a copy of this message | ||
Hello Nathan,
Thursday, July 25, 2002, 7:33:31 PM, you wrote:
NC> You may already be doing it like this, but I think I found a new way to
NC> make select boxes auto-select (what data they put in) a lot easier. All you
NC> have to do is put a variable in each select tag that is equal to the value
NC> of the select option i.e.: <option value=teacher $teacher> -- then all you
NC> have to do is base the variable on that <select name=interest> $$interest =
NC> "selected"; quick and easy with out having to loop through an if elseif
NC> statement. Let me know if you like that method or have any objections.
NC> Full example below.
NC> print("<select name=interest>\n");
NC> // creates a variable with a name based on
NC> // the value of interest with a value of "selected"
NC> $$interest = "selected";
NC> print("<option value=>- Select One -</option>\n");
NC> print("<option value=teacher $teacher>Teacher</option>\n");
NC> print("<option value=lego $lego>Lego Enthusiast</option>\n");
NC> print("<option value=student $student>Student</option>\n");
NC> print("<option value=homeschool $homeschool>Homeschool
NC> Parent</option>\n");
NC> print("<option value=browsing $browsing>Browsing</option>\n");
NC> print("<option value=afterschool $afterschool>Afterschool</option>\n");
NC> print("<option value=bgca $bgca>Boys & Girls Club</option>\n");
NC> print("<option value=ymca $ymva>YMCA</option>\n");
NC> print("</select> \n");
NC> [ Nathan Cook | ncook@pcsedu.com ]
I use the same method with templates (class Template in PHPLib),
I put on your $teacher var my template var {TEACHER} for example
and then just assign to {TEACHER} the value "selected"
--
Best regards,
Alexander Kuznetsov