RE: [PHP] Multiple Select And Javascript Issue - AMMENDED TO ARRAY QUESTION

From: Date: Fri, 25 Aug 2000 06:07:26 +0000
Subject: RE: [PHP] Multiple Select And Javascript Issue - AMMENDED TO ARRAY QUESTION
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-13593@lists.php.net to get a copy of this message
> > >> > 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

« previous php.general (#13593) next »