简体   繁体   English

附加的Javascript文件号

[英]Javascript No. of File attached

It works fine with Google Chrome and Mozilla... But does not work correctly with Internet Explorer. 它在Google Chrome和Mozilla上可以正常使用...但是在Internet Explorer中不能正常使用。

var col = document.getElementById('myFormid');
var fields = col.getElementsByTagName('input');

for(x in fields){
if(fields[x].name == 'doc[]' && fields[x].value != ''){
files++;    
}
}

You shouldn't use for...in to iterate over arrays, as you will access the array's prototype methods along with its elements. 您不应该使用for...in遍历数组,因为您将访问数组的原型方法及其元素。 Just use the regular for syntax and see if that helps: 只需使用普通for语法和看看是否有帮助:

var col = document.getElementById('myFormid');
var fields = col.getElementsByTagName('input');

for (var i = 0; i < fields.length; i++) {
  var field = fields[i];

  if ((field.name == 'doc[]') && (field.value != '')) {
    files++;    
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM