Click to See Complete Forum and Search --> : Where does 'this' refer to the current form?


JSchwarz
07-14-2003, 10:42 AM
How can I create a variable (called thisForm) which points to the current form? Or, when does the JavaScript 'this' keyword refer to the current form?

I call function initialize() in the onLoad of every form. Within initialize() is the line thisForm = document.forms[0];The problem is that not all of the forms are the first form on the page.

What I need is a generic way to refer to the current form, so I can assign it to thisForm.

Thanks in advance.
Jeff

Khalid Ali
07-14-2003, 11:07 AM
this points to the current element for example

<a href="..." onlick="this" here this points to this very anchor tag.

if youwant to pass the form reference to any function from any other element other then the <form element then use this

"this.form" and from the <form element itself only "this" will work

JSchwarz
07-14-2003, 11:53 AM
Thanks, Khalid. One more question: How do I pass the form reference to a function from the form's onLoad event?