Form printing script

Explorer 3 and QNX Voyager can't handle this script.

Escape gives no type for INPUT's without a TYPE attribute (that default to "text").


A script that prints out the form structure for you, so you can keep track of which element has which number etc.

As example I take the same form as on the example form and script page.

Why do you want to learn JavaScript? Dunno
Because my boss told me to
Generally interested
It might come in useful
How did you get to this site?
I'd like additional information about oranges
blue whales

This is the form:


This is the script. Copy-paste it below your form in the same page.

<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>' +;
	document.write('<td>' + current.type);
	document.write('<td>' + current.value + '</tr>');

// -->


Note document.forms[0].length: it is the number of elements in the form.