Entry
JavaScript: Form: Current: Parameter: How to pass current form as parameter to function? [this.form]
Jan 15th, 2005 16:47
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 25 November 2004 - 05:36 pm -------------------
JavaScript: Form: Current: Parameter: How to pass current form as
parameter to function? [this.form]
---
Use e.g. the 'this.form' command.
---
---
e.g.
Here you use
'this.form'
to pass the current form to a function.
--- cut here: begin --------------------------------------------------
<!-------------------------------------------------------------------->
<HTML>
<!-------------------------------------------------------------------->
<HEAD>
<!-------------------------------------------------------------------->
<SCRIPT>
<!-------------------------------------------------------------------->
function PROCTest( form ) {
alert( form.name );
}
<!-------------------------------------------------------------------->
</SCRIPT>
<!-------------------------------------------------------------------->
</HEAD>
<!-------------------------------------------------------------------->
<FORM
NAME="myformname1"
>
<!-------------------------------------------------------------------->
<BUTTON
ONCLICK='
PROCTest( this.form );
'
>
<!-------------------------------------------------------------------->
SHOW NAME OF CURRENT FORM
<!-------------------------------------------------------------------->
</BUTTON>
<!-------------------------------------------------------------------->
</HTML>
<!-------------------------------------------------------------------->
--- cut here: end ----------------------------------------------------
---
---
e.g.
Another use of 'this.form':
Here you use
'this.form'
to refer to another element in the same form,
and
'this'
to refer to the current element in the same form.
--- cut here: begin --------------------------------------------------
<HTML>
<BODY>
<FORM
NAME="myForm"
>
Select here :
<SELECT
name="myList"
onChange="
this.form.myText.value =
this.options[ this.selectedIndex ].text;
"
>
<OPTION value="One">One
<OPTION value="Two">Two
<OPTION value="Three">Three
</SELECT>
<INPUT
TYPE="text"
NAME="myText"
>
</FORM>
</BODY>
</HTML>
--- cut here: end ----------------------------------------------------
---
---
Book: see also:
---
[book: Goodman, Danny - JavaScript bible]
---
---
Internet: see also:
---
JavaScript: Object: Current: Parameter: How to pass current object as
parameter to function? [this]
http://www.faqts.com/knowledge_base/view.phtml/aid/32365/fid/129
----------------------------------------------------------------------