RE: Multiple Select And Javascript Issue
| From: | Grant Walters | Date: | Fri, 25 Aug 2000 21:51:08 +0000 |
| Subject: | RE: Multiple Select And Javascript Issue | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-13746@lists.php.net to get a copy of this message | ||
> I'm interested in hearing your hidden-fields work-around (the part that
> isn't too bad). I need to do something like this, but haven't gotten
> around to trying. The steps I had mentally composed are:
>
> 1. output SELECT element items without the [] on the end of the name.
> 2. bind a function to onChange that updates a hidden field
> 3. hidden field should be urlencoded somehow??
>
> And that's where it gets sketchy. It seems like the hidden field value
> has to be PHP code that populates the array or something. Not directly,
> of course, but somehow.
>
I have just posted another attempt at this. The second post refers to the
fact that HTML only has one hidden type of field. If you give it a name
like Item[], PHP expects it as an array.
I have attached this to the FORM element of the HTML page.
ONSUBMIT="return SetHidden(this)"
I then cycles through the SELECT object and populates a hidden field. I've
tried building and attaching a Javascript array but it jst comes out with
comma delimited values. This isn't bad as I can explode them out anyway. I
just thought that a real array would be useful.
> If that's what you're doing, then you could at this stage also just insert
> into $HTTP_POST_VARS, right?
Is HTTP_POST_VARS actually writeable from Javascript?
> >
> > SELECT with MULTIPLE options is being built by Javascript code
> that won't
> > accept a variable name like "items[]" so it fills a field
> called "items".
> >
> > This is'nt too bad as I can work around it with a hidden field.
> >
> > The problem is that PHP doesn't populate HTTP_POST_VARS with the entries
> > from "items" unless they are acutally selected.
> >
> > Can I get PHP to return all values from the SELECT MULTIPLE variable?
> >
Regards
GRANT WALTERS
Walters & Associates, P O Box 13-043, Johnsonville, Wellington, New Zealand
Phone: +64 4 4765175 CellPhone: 025 488265