> -----Original Message-----
> From: Rich Gray [mailto:[EMAIL PROTECTED]]
> 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: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to