<script>
for (i=0;i<document.formname.all.elements.length;i++)
{
alert(document.formname.all.elements[i].name))
}
</script>

解决方案 »

  1.   

    那么又如何知道html中有多少个form呢?
      

  2.   

    <form>
    </form>
    <form>
    </form>
    <form>
    </form>
    <script>alert(document.forms.length)</script>
      

  3.   

    tags Method--------------------------------------------------------------------------------Retrieves a collection of objects that have the specified HTML tag name. SyntaxcollElements = object.tags(sTag)
    ParameterssTag Required. String爐hat specifies an HTML tag. It can be any one of the objects exposed by the DHTML Object Model. Return ValueReturns a collection of element objects if successful, or null otherwise.ResThis method returns an empty collection if no elements having the given name are found. Use the length property on the collection to determine the number of elements it contains. ExampleThis example uses the tags method to retrieve a collection of all P elements in the document, and then uses the textDecoration property to underline each element.<SCRIPT LANGUAGE="JScript">
    var coll = document.all.tags("P");
    if (coll!=null)
    {
        for (i=0; i<coll.length; i++) 
          coll[i].style.textDecoration="underline";
    }
    </SCRIPT>
    Applies To all, anchors, applets, areas, boundElements, cells, children, elements, embeds, forms, images, links, options, plugins, rows, scripts, tBodies 
      

  4.   

    document.all.tags("table").length可以获得表格的个数1