0

Hello, I am trying to write a simple javascript to read all forms. My ReadForm function works right. I tried it out of ReadAllForms function, there is no problem with it.

I think document.getElementsByTagName returns false. Why can this happen?

function ReadAllForms() {
    if (document.getElementsByTagName)

        var myforms = document.getElementsByTagName("form");
        alert(myforms.length);
        for (var i =0; i < myforms.length; i++) {
            ReadForm (myforms[i]);
        }
    }
}
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by PierlucSS
0

Hello, I am trying to write a simple javascript to read all forms. My ReadForm function works right. I tried it out of ReadAllForms function, there is no problem with it.

I think document.getElementsByTagName returns false. Why can this happen?

function ReadAllForms() {
    if (document.getElementsByTagName)

        var myforms = document.getElementsByTagName("form");
        alert(myforms.length);
        for (var i =0; i < myforms.length; i++) {
            ReadForm (myforms[i]);
        }
    }
}

It's not getting in the if because you didn't define which tag you want to get and because getElementByTagName is not returning a boolean.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.