Function used to establish a pointer to a form.

Syntax

JSV_formPointer(expV)

Prototype

n/a

Returns

The formPointer function returns a pointer to the passed form specification.

Parameters

The formPointer function uses the following argument.

Argument Description
expV The variant can be either a string that defines the form reference or a form reference.

String Examples
  • "document.PointerTest"
  • "document.forms[0]"
  • "document.forms[0].name"
Reference Examples
  • document.PointerTest
  • document.forms[0]
  • this.form

Remarks

The purpose of this function is to reduce the amount of code in a function to when dealing with form pointers. formPointer reduces tha amount of code in each function that uses it by allowing the programmer to pass either a string or the form pointer itself and not be concern about which is being passed.

Dependencies

n/a

Example

The following lines of code

<FORM ACTION="formPointer.htm" NAME="PointerTest" onSubmit="return false;">
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2">
<TR VALIGN="middle">
    <TD ALIGN="right"><B>Movie Title #1:</B></TD>
    <TD ALIGN="left"><INPUT TYPE="text" NAME="Field1" VALUE="" SIZE="32" MAXLENGTH="124"></TD>
</TR>
<TR>
    <TD ALIGN="right"><B>Movie Title #2:</B></TD>
    <TD ALIGN="left"><INPUT TYPE="text" NAME="Field2" VALUE="" SIZE="32" MAXLENGTH="124"></TD>
</TR>
</TABLE>
<BR>
<INPUT TYPE="button" VALUE=" this.form Test " onClick="testArg(this.form, 'ALERT');">
</FORM>

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
function testArg(formObj, displayMethod) {
    with ( JSV_formPointer(formObj) ) {
        if (displayMethod == "ALERT") alert(Field1.value);
        else document.write( Field2.value + "<BR><BR>" );
    }
}

function initializeFormFields() {
    with ( JSV_formPointer("document.PointerTest") ) {
        Field1.value = "Galaxy Quest";
        Field2.value = "Men in Black";
    }
}

initializeFormFields();

document.write( "document.forms[0].name (reference): " );
testArg(document.forms[0].name);
document.write( "document.PointerTest (string): " );
testArg("document.PointerTest");
document.write( "document.forms[0] (reference): " );
testArg(document.forms[0]);
document.write( "document.forms[0] (string): " );
testArg("document.forms[0]");
</SCRIPT>

produce

Movie Title #1:
Movie Title #2: