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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

One radio button - Weird Error

Status
Not open for further replies.

countdrak

Programmer
Jun 20, 2003
358
US
Does anyone know if the why

thisform.shipadd.length is undefined when I have only one radio button with the name shipadd.

I am trying to validate a radio button and My for loop doesnt work when I have only one radio button.

for (counter = 0; counter < thisform.shipadd.length; counter++)

Any help would be great. Thanks guys

 
Hi

In FireFox if you say :
Code:
alert(document.thisform.shipadd)
will show "[highlight #eee][object HTMLInputElement][/highlight]".

So there is no [tt]lenght[/tt] because there is no [tt]Array[/tt] or [tt]HTMLCollection[/tt].

Test it before using :
Code:
if (thisform.shipadd.length)
for (counter = 0; counter < thisform.shipadd.length; counter++)
[gray]// ...[/gray]

Feherke.
 
Hi

By the way, you have something like this before that code, right ?
Code:
thisform=document.formName;
If not, I suggest to use standard compliant references. Only the highest level [tt]Object[/tt] in the hierarchy, the [tt]window[/tt] is optional, the [tt]document[/tt] is not.
Code:
if ([red]document.[/red]thisform.shipadd.length)
for (counter = 0; counter < [red]document.[/red]thisform.shipadd.length; counter++)
[gray]// ...[/gray]

Feherke.
 
Great The document.thisform fixed it!

Thanks guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top