Message
 
To
11/07/2001 16:38:48
General information
Forum:
Internet
Category:
Javascript
Miscellaneous
Thread ID:
00529433
Message ID:
00529444
Views:
13
>From a form action, I am calling a javascript function with the form object. However, the this syntax doesn't seem to work. I have to pass document.forms instead.
>
>This doesn't work.
>
>
>...FORM NAME=Sujet ACTION=javascript:Go(this)
>
>< SCRIPT>
>function Go(toForm)
>{
>   alert(toForm.MyField.value);
>}
>
>
>This works.
>
>
>...FORM NAME=Sujet ACTION=javascript:Go(document.forms.Sujet)
>
>< SCRIPT>
>function Go(toForm)
>{
>   alert(toForm.MyField.value);
>}
>
>
>Why?

Michel;

I may be wrong but I presume you are referring to an HTML form. To me the syntax would be incorrect when attempting to use the word “this” to address the form. The form would not know what you were requesting, regardless of what scripting language was in use. “This” is a term from a methodology used to address an object such as in Visual FoxPro. The term “object” may be misunderstood when going from one programming environment to another. Using VFP, VB or HTML would require different syntax for addressing an object.

Tom
Previous
Next
Reply
Map
View