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: AZ Pete
Date:  
To: plug-discuss
Subject: Re: building html form select menus from arrays in php
You forgot to put a value between your <option value="john"></option> tags.
change this:
echo '>'.'</OPTION>';
to this:
echo '>'.$picklist[$x].'</OPTION>';


At 3/6/2005 06:18 PM, you 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>';
>}

>
>$picklist = array("john", "paul", "george", "ringo");
>
>echo '<html><body>';
>echo '<form action="http://linuxserver/horde/horde-utils/test2.php"
>method="post" target="db_get_attributes">';
>build_select_box($picklist);
>echo '<input type="submit" name="OK" value="OK">';
>echo '</input></form></body></html>';
>?>
>
>It should be obvious what I am trying to get - is a pull down 'select'
>menu with the 4 names listed and I am actually going to pass this a much
>larger array when time comes.
>
>I can't make this work...what's the secret?
>
>Note that if you try to copy/paste - the line that starts
>echo '<form action...
>
>will wrap to the next line
>
>Craig
>
>---------------------------------------------------
>PLUG-discuss mailing list -
>To subscribe, unsubscribe, or to change you mail settings:
>http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss


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