[thelist] Select - forms

.jeff jeff at members.evolt.org
Mon Mar 10 11:31:03 CST 2003


chris,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Chris Marsh
>
> document.forms[n].submit() (where n is the 0-based index
> of the form on the page)
> document.forms['formNAME'].submit() (where formNAME is
> the value of the name attribute of the form)
> document.formNAME.submit() (where formNAME is the
> value of the name attribute of the form)
>
> I would recommend the latter, as it is both explicit
> and elegant (IMHO), and does not fall over if the
> order of forms on the page changes.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

i have a suggestion that's even more elegant and failproof.  read on.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> onchange='document.formNAME.submit()'
>
> Then every time the selection is changed, the form will
> be submitted.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

since you're calling an event on a form element you can get access to the
containing form using the "this" keyword.

onchange="this.form.submit()"

told ya it was better.

;)

.jeff

http://evolt.org/

NOTICE:  members.evolt.org web and email address are changing!
---------------------------------------------------------------------
| OLD:                            | NEW:                            |
| jeff at members.evolt.org          | evolt at jeffhowden.com            |
| http://members.evolt.org/jeff/  | http://evolt.jeffhowden.com/    |
---------------------------------------------------------------------





More information about the thelist mailing list