RE: [PHP] populate form input option dropdown box from existingdata

2009-06-16 Thread Dajve Green
Ack, yes - my bad. Missed the select name square brackets when I sent my
example.

And yeah, the only real difference between a multiple select and checkbox is
which works best with the UI (and, more often than not, how confused the
concept of multiple selects makes your end-user)

--

for (thoughts, ramblings && doodles) {
  goto http://dajve.co.uk ;
}
 

> -Original Message-
> From: tedd [mailto:tedd.sperl...@gmail.com]
> Sent: 16 June 2009 19:05
> To: php-general@lists.php.net
> Subject: Re: [PHP] populate form input option dropdown box from
> existingdata
> 
> At 10:42 AM -0500 6/16/09, Shawn McKenzie wrote:
> >He has a multiple select, so the select has to be an array or you just
> >get one value even if more than one was selected (you just get the last
> >one).
> 
> Okay, it's not that much different than using check-boxes -- here's
> the solution for that:
> 
> http://www.webbytedd.com/bbb/check-box-form/index.php
> 
> and here's the select solution:
> 
> http://www.webbytedd.com/bbb/select-box-form/index.php
> 
> The point is to use name="option[]" (i.e., name the array) and allow
> the browser to populate the POST array. Then on the php side of
> things, simply pull out the data from the POST array via the array's
> name.
> 
> You can see how this is done via the above links.
> 
> 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



Re: [PHP] populate form input option dropdown box from existingdata

2009-06-16 Thread tedd

At 10:42 AM -0500 6/16/09, Shawn McKenzie wrote:

He has a multiple select, so the select has to be an array or you just
get one value even if more than one was selected (you just get the last
one).


Okay, it's not that much different than using check-boxes -- here's 
the solution for that:


http://www.webbytedd.com/bbb/check-box-form/index.php

and here's the select solution:

http://www.webbytedd.com/bbb/select-box-form/index.php

The point is to use name="option[]" (i.e., name the array) and allow 
the browser to populate the POST array. Then on the php side of 
things, simply pull out the data from the POST array via the array's 
name.


You can see how this is done via the above links.

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



Re: [PHP] populate form input option dropdown box from existingdata

2009-06-16 Thread Shawn McKenzie
tedd wrote:
> 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
>> 
>> Civilization
>> Monuments, Temples & Tombs
>> Pharaohs and Queens... 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
> 
> 
>Civilization
>Monuments, Temples & Tombs
>Pharaohs and Queens
> 
> 
> 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
> 

He has a multiple select, so the select has to be an array or you just
get one value even if more than one was selected (you just get the last
one).

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php