RE: [PHP] Multiple selections

From: Date: Wed, 13 Nov 2002 13:25:11 +0000
Subject: RE: [PHP] Multiple selections
Groups: php.general 
Request: Send a blank email to php-general+get-124207@lists.php.net to get a copy of this message
> -----Original Message----- > From: David Rice [mailto:davidrice@rogers.com] > Sent: 13 November 2002 01:00 > > On Tuesday, November 12, 2002, at 07:34 PM, Ernest E > Vogelsinger wrote: > > > > Sure it is - just name the listbox control "myvar[]" (note the angle > > brackets). PHP will recognize this being an array, and > you'll end up > > with > > $myvar = array('select1','select2'); > > Is this the only way to do this? Yes. > I just had to do some work with JavaScript and forms and the > "myvar[]" > name clobbered JavaScript's access to form elements by name. I had to > do some ugly form.elements[x] looping to get at the "myvar[]" control. > > This kind on external language hostility is not that cool, especially > toward such a common language as JavaScript. > > My apologies to PHP if the language provides a workaround :) Not even a workaround. By definition, in JavaScript x.y is identical to x['y'], so where for a simple field you might write: document.formname.myvar.value for a field named "myvar[]" you can write: document.formname['myvar[]'].value Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#124207) next »