RE: Re: deleting records using a checkbox

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Paul Burney [mailto:paul.lists@burney.ws]
> Sent: 20 March 2003 15:22
> 
> on 3/20/03 1:45 AM, olinux at olnx@yahoo.com appended the 
> following bits to
> my mbox:
> 
> > [ and ] are illegal characters. #javascript
> 
> I'm coming into this a bit late, so I'm not sure exactly what 
> you wish to
> do.
> 
> You can use JavaScript to refer to checkbox items in the format:
> 
> document.forms[formindex].elements[elementindex].property

You can also use the form and element names in the brackets, so:

  document.forms["formname"].elements["elementname"].property

This is more human-friendly, and doesn't require you to change the index
number if you add or remove elements (or forms!).

However, if you prefer, you don't even need the ".forms" or ".elements"
parts.  Since, in JavaScript, *by definition*

  x.y === x["y"]

if you have a form element defined as:

  <form name="example" ... >

      <input type="checkbox" name="delete" ... />

   </form>

you can refer to this as

   document.example.delete

or

   document.example["delete"]

or

   document["example"].delete

or

   document["example"]["delete"]

And, of course, an obvious extension of this is that if the input element on
your form is:

      <input type="checkbox" name="delete[]" ... />

you can refer to this as:

   document.example["delete[]"]

This is just a basic recipe -- add your own ingredients, and mix and cook to
suit!

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 

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux