I have a form with about 10+ input elements in it… For testing, I’d like to alert all their values… Is there a quicker way than this:
var f = document.getElementById('myForm').getElementsByTagName("INPUT");
alert(f[0].name + ' ' + f[0].value);
alert(f[1].name + ' ' + f[1].value);
alert(f[2].name + ' ' + f[2].value);
... and so on...
You’ll want to use a for loop for that.
If you are just testing/debugging things, I’d recommend using your browser’s console. Using Chrome or Firefox + Firebug you can call the
console.logmethod and then drill down into your object. This tends to be a bit easier to manage in my opinion.