this is just an example of how you can use the for loop in a javascript code:

JAVASCRIPT CODE:
<script type="text/javascript" language="javascript">
function submitted(){
	var form = document.myform2
	for (i = 0; i < form.elements.length; i++) {
		alert(document.getElementById(i).value);
	}
}
</script>