View Full Version : error: "has no properties" in function

11-13-2004, 01:09 AM
I am working on a loop that counts my elements. When I debug, I get the error "e.elements[i] has no properties" (line 10).

I have defined i as a variable with value of 0, and a form passes to e. So, I have both i and e defined as something... What's my problem? I don't understand how neither of them has properties. (Or which one, for that matter, doesn't have properties).

function countElements(e){
var rb=0
var b=0
var tb=0
var cb=0
var i=0
var totalNum=e.elements.length

if (e.elements[i].type=="text")tb=tb+1;
else if (e.elements[i].type=="button")b=b+1;
else if (e.elements[i].type=="radio")rb=rb+1;
else if (e.elements[i].type=="checkbox")cb=cb+1

Thanks again,

11-13-2004, 01:23 AM
when i = length, the error will occur, because the collection is zero-based, so change "i<=totalNum" to "i<totalNum"

11-13-2004, 08:46 AM
Whoa, that was all? Thanks codegoboom!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum