View Full Version : this.fom inside "form" tag not working?

05-27-2004, 04:54 PM
Hi everyone,

I'm trying to execute a javascript function in the following manner:

<form name="someform" action="somepage" method="post" onsubmit="return enableChk(this.form);">

The function is:

function enableChk(form1){

The function gets called well, but the alert gives "undefined", so I'm guessing that you can't use "this.form" inside a <form> tag. Can anyone confirm this?

I could hardcode the form name inside the function but i want it to be re-usable, so afaik "this.form" is the only way to go. If all else fails i'll use the function on a submit button instead, which should work (in theory), but i'd like to be able to use it in the <form> tag.

Thanks for any input! (pun intended :) )

05-27-2004, 05:36 PM
I believe you need to use "this" instead of "this.form". try that and see if it works.

05-27-2004, 07:08 PM
Thanks a bunch!

Of course! It makes sense that "this" used in the form tag would pass the form itself. Previously I was using the code on a regular link, which needed "this.form" to work properly, and it just didn't occur to me that i'd need to use only "this" when i switched to using it in the form tag.

Thanks again!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum