[Javascript] Passing an object and/or a form reference to a function
Paul Novitski
paul at novitskisoftware.com
Fri Jul 9 13:15:09 CDT 2004
At 10:28 AM 7/9/2004, dev at qroute.net wrote:
>How do you pass a form reference to a form validation function so that in
>that function body I don't have to spell the whole thing as
>
>function Validate()
>{
>aValue = window.document.formNameHere.ObjectNameHere.value
>}
The form property of an object is its parental form, therefore:
<input onclick="DoSomething(this)" ...>
function DoSomething(argControl)
{
// get the control's containing form
var oForm = argControl.form;
}
or:
<input onclick="DoSomething(this.form)" ...>
function DoSomething(argForm)
{
// argForm is the containing form
}
Paul
More information about the Javascript
mailing list