Re: building html form select menus from arrays in php

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Craig White
Date:  
To: plug-discuss
Subject: Re: building html form select menus from arrays in php
On Sun, 2005-03-06 at 18:56 -0700, June Tate wrote:
> On Mar 6, 2005, at 6:18 PM, Craig White wrote:
> > spent a lot of time today on this - researching and can't seem to make
> > it work.
> >
> > <?php
> >
> > function build_select_box ($picklist) {
> >
> >   echo '<SELECT NAME="'."drop_list".'">';
> >   for ($x=0; $x<count($picklist); $x++) {
> >     echo '<OPTION VALUE="'.$picklist[$x].'"';
> >     echo '>'.'</OPTION>';
> >   }
> >   echo '</SELECT>';
> > }

>
> On my setup, it seems to work, but without displaying any labels. Your
> values are there, but you're not giving a human-readable name for each
> option in the select list. As a result, it shows up as a blank list.
>
> Change your <option> HTML to read the following:
>
>     echo '<OPTION>'. $picklist[$x] .'</OPTION>';

>
> And it should display a list the way you're wanting. The value
> attribute is only used for enumerated lists where you are mapping
> human-readable values to database values (i.e., phone call result
> codes). If you don't specify a value attribute, the browser will use
> the value between the <option></option> tags as the actual value.

----
OK - got it...thanks

spent a lot of time working on this issue - finally reduced it down to
something really simple to ask the question which solved most of my
problems but you finished it.

I guess that is a technique that I need to get through my thick
head...keep it simple.

Thanks

Craig

---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss