[Javascript] Passing an object and/or a form reference to a function

Flavio Gomes flavio at economisa.com.br
Fri Jul 9 13:03:08 CDT 2004


Both?

 The form submit will be triggered when any of the submits on the form 
be pressed.
But, if you have only one submit, in the end it'd be the same.
  and you *can* do something like this:

function Val(frmObject)
{
  alert(frmObject.value)
}

function Validate(frm)
{
 alert(frm.frmObject.value)
}

then
=========//=========
<form name=myForm onsubmit="Val(document.form.myInput)">
  <input name=myInput />
  <input type=submit onclick="Validate(document.form)"/>
</form>
=========//=========

Will both work.




---
Flavio Gomes
flavio at economisa.com.br



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
>}
>
>It'd better If I could do sometihng like
>
>function Val(frmObject)
>{
>aValue = frmObject.value
>}
>
>and/or
>
>function Validate(frm)
>{
>aValue = frm.frmObject.value
>}
>
>On the onSubmit event of a form , or on the onClick event of an object, How
>do you call the Validate function so the above idea can be realized ?
>  
>



More information about the Javascript mailing list