[liphp] populating option label dynamically

Christopher R. Merlo [email protected]
Fri, 6 Jun 2003 18:40:15 -0400


On 2003-06-06 18:35 -0400, Venkatagiriyappa, Veena <[email protected]> wrote:

>  So, when the member logs into our web page, he has an option to view his
> profile as well as edit it. I don't know to dynamically change the option
> label selected depending on the member.

The <option> tag has an optional attribute called "selected", which
will be the default value when the form shows up.  So, I usually do
something like:

while( /* reading titles from the DB or whatever */ ) {
    print "<option value=\"$value_from_the_db\"";
    if( /* $value_from_the_db is this user's title */ ) {
        print " selected";
    }
    print ">\n";
}

Something like that.
-c

-- 
[email protected]        http://turing.matcmp.ncc.edu/~cmerlo

Windows:  More than enough rope.