The object you get with .getElementsByTagName
is not an array
but is a nodeList
. You have to turn it to an array before you put it in a loop to use more efficiently and in those cases i prefer .forEach
rather than for.
To make the array :
var array = Array.prototype.slice.call(arreglo);
To loop the array
array.forEach(function(elem){
if(elem.getAttribute("type")=="text"){
....