Re: Multiple Select And Javascript Issue - AMMENDED TO ARRAY QUESTION

From: Date: Fri, 25 Aug 2000 06:11:47 +0000
Subject: Re: Multiple Select And Javascript Issue - AMMENDED TO ARRAY QUESTION
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-13594@lists.php.net to get a copy of this message
I'd do it by assigning them to an array first an then attaching the array to the form. eg. "$list[0] = 'testing'; $list[1]='testing again';" etc... then do "document.formName.['items[]'].value = $list;". -mic ----- Original Message ----- From: "Grant Walters" <Grant.Walters@walters.co.nz> To: <php-general@lists.php.net> Sent: Friday, August 25, 2000 4:07 PM Subject: RE: [PHP] Multiple Select And Javascript Issue - AMMENDED TO ARRAY QUESTION > > > >> > Scenario as follows: > > > >> > > > > >> > 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? > > > >> > > > > >> Maybe this is relevant? > > > >> http://au.php.net:81/FAQ.php/#7.14 > > > >> > > > > > > > > The bit about the [] is. I managed to suss that one myself. > > My problem > > is > > > > still that PHP seems to only propagate the values if all of the values > > are > > > > selected. Or is it the Browser? not passing them. > > > > > > > > I need to obtain all the values in the select list whether they are > > selected > > > > or not. > > > > > > > > Regards > > > > > > It's not so much that PHP propagates them as they are only sent if set. > > > The data might well come from a form that is pure html and not parsed by > > > php. If you need the values of all the options, you may need to pass > > > them another way - hidden field, perhaps or could you keep them in a > > > database and do a lookup as required? > > > > > > > I don't think PHP has anything to do with the form values being sent, it's > > just the browser that doesn't send them. I'd say the option > > mentioned below > > of using a hidden field and an array to pass the values on to PHP. > > > > I have hit a snag anyway as I tried the following: > > I created a second SELECT group that is updated with the selected option set > to true. Works beuatifully except you can't hide a SELECT input field. > So... > > I now have a INPUT HIDDEN field called "items[]" which I populate with all > of the options from the SELECT list (more later). > > This is good except for one thing. While PHP decides that the variable is > an array because of the [], it contains only one element with all of the > options, so... > > When I build the string for the field, is there a terminator I can use to > trick PHP into recognising it as the end of an array element? > > Such as document.formName.['items[]'].value = "0\nfirst item\n1\nsecond > item\n3\nthird item\n" > > In the mean time I'll just modify the code to "explode" the values. > > Regards > > GRANT WALTERS > Walters & Associates, P O Box 13-043, Johnsonville, Wellington, New Zealand > Phone: +64 4 4765175 CellPhone: 025 488265 > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#13594) next »