RE: [PHP-DB] HTML Forms question...
| From: | Ford, Mike [LSS] | Date: | Tue, 19 Nov 2002 18:35:06 +0000 |
| Subject: | RE: [PHP-DB] HTML Forms question... | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-23489@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Rich Gray [mailto:rich@f1central.net]
> Sent: 20 November 2002 01:13
>
> If you name the checkbox as name="system[]" then PHP will
> automatically
> create an array of the checkbox values which can be
> subsequently accessed
> via $_POST['system'][n] - be warned however that the '[]' can
> screw up any
> JavaScript code that refers to the checkbox object...
G'rrrr -- not this old chestnut again!
It only "screws up" your JavaScript if you don't write your JavaScript to
allow for it.
It's really very simple: *by* *definition* in JavaScript, the notation
a.b
is *identical* to
a["b"]
Thus, if you have a single checkbox named with name="system", then you can
access it in either of these ways:
document.form.system
document.form["system"]
By extension, if you have multiple checkboxes all named with
name="system[]", you can refer to them as:
document.form["system[]"][0]
document.form["system[]"][1]
document.form["system[]"][2]
etc...
I know this works because I've been using it for years (even before I
started programming with PHP!).
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