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]);
        }
    }
}

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.