RE: populate form input option dropdown box from existing data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A *multiple* select control, as in Phil's initial request will return an
array, however.


> -----Original Message-----
> From: tedd [mailto:tedd.sperling@xxxxxxxxx]
> Sent: 16 June 2009 15:58
> To: PJ; php-general@xxxxxxxxxxxxx
> Subject: Re:  populate form input option dropdown box from existing
> data
> 
> At 6:09 PM -0400 6/15/09, PJ wrote:
> >I am having difficulties figuring out how enter retrieved data into a
> >dropdown box for editing. Here's a snippet:
> >...snip
> ><select name="categoriesIN[]" multiple size="8">
> >         <option value="1">Civilization</option>
> >         <option value="2">Monuments, Temples &amp; Tombs</option>
> >         <option value="3">Pharaohs and Queens</option>... snip
> >
> >As I understand it, I need to put an array ( $categoriesIN[] ) somewhere
> >in the above code... or do I need to insert a series of value "selected"
> >fields for the values?
> >The closest thing to what I need, seems to be in this post:
> >http://www.hpfreaks.com/forums/index.php?topic=165215
> >But it doesn't appear too inviting... not sure if they ever got it to
> >work...
> 
> Think about it. A Select control returns *one* value and not an
> array. As such you don't need to provide an array to collect a single
> value.
> 
> Here's the solution:
> 
> HTML
> 
> <select name="categories" >
>     <option value="1">Civilization</option>
>     <option value="2">Monuments, Temples &amp; Tombs</option>
>     <option value="3">Pharaohs and Queens</option>
> </select>
> 
> PHP
> 
> $category = $_POST['categories'];
> 
> The variable $category will contain 1, 2, or 3 after a post form submit.
> 
> Try it.
> 
> The reference/link you cite above is for a dynamic select control
> that incorporates javascript to populate the second select control.
> It's not a simple select.
> 
> If you are looking to understand what basic html does, try this:
> 
> http://www.htmlcodetutorial.com/
> 
> I often use this site to refresh my failing memory about html stuff.
> 
> Cheers,
> 
> tedd
> 
> --
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 
> --
> 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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux