js 数组取元素
var strs = document.getElementsByName("ziValue");
var ziDuans = document.getElementsByName("ziDuans");
var fuHaos = document.getElementsByName("fuHaos");
var values = "";
var duans ="";
var haos="";
var arrDuan = new Array();
var arrHao = new Array();
var arrValue = new Array();
for(var j=0;j<ziDuans.length;j++){
arrValue[j]=strs[j].value;
arrDuan[j]=ziDuans[j].value;
arrHao[j]=fuHaos[j].value;
}
for(var i=0;i<strs.length;i++){
// alert(arrValue[j].value);
if(strs[i].value.length==0){
arrValue = removeElement(i,arrValue);
arrDuan = removeElement(i,arrDuan);
arrHao = removeElement(i,arrHao);
}else{
values += arrValue[i]+",";
duans += arrDuan[i]+",";
haos += arrHao[i]+",";
}
}
得到的values总是一个"undefined,",取数组元素不是arrValues[i] 这么个取法吗?
------解决方案--------------------
可能removeElement(i,arrValue); 就返回了一个undefined