"Scott Navarre" <sm*@asus.net> wrote in message
news:bu*********@enews4.newsguy.com...
<snip>
function formNameTest(oThis)
{
alert('Form name is "'+oThis.form.name+'"')
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="Test">
<INPUT TYPE="TEXT" NAME="TestText" onClick="formNameTest(this)">
</FORM>
</BODY>
</HTML>
and what it ends up displaying in the alert window is
"[object]" instead of the form's name. I have also tried
using 'oThis.form.name.value' which gives "".
And finally, I tried passing 'this.form' to my fuction
(and modified my function) instead of 'this', with no luck.
When you post code claming that it demonstrates a problem it is a good
idea to test it to ensure that id does exhibit the problem. The code you
posted will not exhibit the problem described because that is being
caused by one of the controls that you have placed within the real form
HTML having the name (or possibly ID) "name". When the reference to that
control is added to the form as a named property of the form, under its
name "name" it overwrites the form's original - name - property and
renders the name of the form inaccessible to scripts.
If you had tested the code you posted you would have noticed it working
and had reason to suspect that it was a difference between that code and
the original that explained the problem.
It is best to never give the controls within a form NAME (or ID)
attributes that correspond with existing properties of the form object.
And it is easy to avoid as JavaScript is case sensitive so only changing
to initial capitals in the control names would avoid the problem
entirely.
Richard.