Connecting Tech Pros Worldwide Help | Site Map

form.elements[x] has no properties

jeep@13.usenet.us.com
Guest
 
Posts: n/a
#1: Jul 20 '05
I get this in the following javascript:

Error: form.elements[x] has no properites

For the following function:

function check_elems(form,q,st,end) {
var flag = false;
if (end < st) { alert("check_elems(): invalid st "+st+" and end "+end); }
for (var x = st; x <= end; x++) {
//alert(x);
if (form.elements[x].checked) {
flag = true;
}
}
if (!flag) {
// alert("Please answer question " + q +
// " and any others you may have forgotten.");
}
return flag;
}

After hours of trying to find the answer, I give up!

Any help is appreciated,
Jeff


Lasse Reichstein Nielsen
Guest
 
Posts: n/a
#2: Jul 20 '05

re: form.elements[x] has no properties


jeep@13.usenet.us.com writes:
[color=blue]
> I get this in the following javascript:
>
> Error: form.elements[x] has no properites[/color]

So x is probably too large.
[color=blue]
> function check_elems(form,q,st,end) {
> var flag = false;[/color]

Add:
if (end >= form.elements.length) { alert ("this is not happening!");}
and see if it is happening.

/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
jeep@13.usenet.us.com
Guest
 
Posts: n/a
#3: Jul 20 '05

re: form.elements[x] has no properties


>> Error: form.elements[x] has no properites
[color=blue]
> So x is probably too large.
> Add:
> if (end >= form.elements.length) { alert ("this is not happening!");}
> and see if it is happening.[/color]

Oh DUH! You are right. I split up a very long page and never changed
the element numbers!

Thank you!
Jeff
Closed Thread