Forum Moderators: open
function runChange(f)
{
var elem = f.elements;
var flength = elem.length;
var i = 0;
document.write("flength: ");
document.write(flength);
for (i=0; i <= flength; i++)
{
document.write("<br>"+i+") ");
if ( elem[i] )
{
document.write("- ");
if (elem[i].type == "text")
{
document.write("Type["+i+"]: Text");
}
else if (elem[i].type == "checkbox")
{
document.write("Type["+i+"]: Checkbox");
}
else if (elem[i].type == "radio")
{
document.write("Type["+i+"]: radio");
}
else if (elem[i].type == "reset")
{
document.write("Type["+i+"]: radio");
}
else if (elem[i].type == "button")
{
document.write("Type["+i+"]: radio");
}
}
}
}
I have no idea what could be wrong with it, but this is the output:
flength: 49
0)
1)
2)
3)
4)
5)
6)
7)
8)
9)
10)
11)
12)
13)
14)
15)
16)
17)
18)
19)
20)
21)
22)
23)
24)
25)
26)
27)
28)
29)
30)
31)
32)
33)
34)
35)
36)
37)
38)
39)
40)
41)
42)
43)
44)
45)
46)
47)
48)
49)
So its clearly looping, but it looks like everything single one of the elements doesn't exist? How could this be? Also, if I change it to this:
document.write("flength: ");
document.write(flength);
flength = elem.length;
document.write("<br>flength: ");
document.write(flength);
I get these results:
flength: 49
flength: 0
0)
Data corruption? I have no idea whats going wrong here. Any help would be greatly appreciated.