Javascript Show Form Structure

From LinuxServerTech

Jump to: navigation, search

Found this really nice javascript thingy at http://www.quirksmode.org/js/formpr.html. Insert it after a form, and it will dump the structure of the form for you. Very useful if you are having problems figuring out what kind of monster you have created when trying to access form elements.

 
 <table border=1><tr><th>element</th><th>name</th><th>type</th><th>value</th>
    <script language="javascript" type="text/javascript">
    <!--
     for (var i=0;i<document.forms[0].length;i++) {
        current = document.forms[0].elements[i];
        document.write('<tr><td>' + i);
        document.write('<td>' + current.name);
        document.write('<td>' + current.type);
        document.write('<td>' + current.value + '</tr>');
     }

    // -->
    </script>
 </table>