Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting error saying 'not an object'... 1

Status
Not open for further replies.

Unsubscribed

Programmer
Jun 8, 1999
11
CA
Hi,

I have the following code:

...
if (document.applicationForm.firstname.value == "")
{
alert("Please enter your first name.");

document.applicationForm.firstname.select();

document.applicationForm.firstnamelabel.focus();

return false;

}

When this runs, I get the error saying document.applicationForm.firstnamelabel is not an object. However, it is defined further down the page in the form as follows:

<tr>
<td valign=&quot;top&quot; WIDTH=&quot;30%&quot;>
<b><LABEL ID=&quot;firstnamelabel&quot; FOR=&quot;firstname&quot;>First Name:</LABEL></b><br>
</td>
<td valign=&quot;top&quot; WIDTH=&quot;65%&quot;>
<INPUT TYPE=&quot;Text&quot; NAME=&quot;firstname&quot; VALUE=&quot;&quot; MAXLENGTH=&quot;40&quot; ID=&quot;firstname&quot; TABINDEX=&quot;1&quot; onFocus=&quot;nextfield ='lastname';&quot;>
</td>
</tr>

Could anyone let me know what I've done wrong here? Thanks :)
 
document.applicationForm.firstnamelabel.focus();

should be:

firstnamelabel.focus();


luciddream@subdimension.com
 
Thanks for the suggestion...this doesn't work quite right for me... it highlights the url in the address bar in IE, and Netscape 4.7 ignores it and goes on with submitting the form (says firsnamelabel is 'undefined').

I am trying to put focus on the label and select the contents of the textbox the user didn't fill in. I was doing it by just setting focus to the text box, which worked fine except that in Netscape (4.7 only) the page would shift over so that the text box would be at the left side of the screen, causing the user to have to scroll over to see the label...

Any suggestions please?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top