[thelist] form.fieldname notation

Scott Brady evolt at scottbrady.net
Mon Dec 9 10:53:01 CST 2002

I've got yet another JS dilemma.  It appears that a form field isn't referenceable within a form.

Here's a code example (this is IE-specific code):

-------------- BEGIN CODE ---------------
<script language="JavaScript" for="searchform" event="onsubmit">
	// Loop of form fields ("validate" is an attribute of
	// some of the form fields)
	for (i=0; i<this.length; i++)
		if (this[i].validate)
return false;

<form method="post" action="/whatever.cfm" id="searchform"  name="searchform">
<input type="text" class="textbox" id="patientsearch" name="patient_id" validate="true">
----------------------- END CODE --------------------

The input text box has a name value which changes dynamically based on an event (not included in this code sample).  One of the values it changes to is "ssn" for Social Security Numbers.  When that has occurred and you submit the form, the two alert boxes say "ssn" (for "this[i].name') and "undefined"  (for "this.ssn").

Shouldn't the second alert box say "[object]"??

I've tried all sorts of different ways of referencing that field:

They all result in "undefined".

Would it have to do with the text box's id value being something else?

Thanks in advance!

Scott Brady

More information about the thelist mailing list