我有这个 javascript。我的表单中肯定有 2 个名为“附件”的输入标签:
<input name="attachments" type="hidden" value="test.doc">
<input name="attachments" type="hidden" value="test2.doc">
这是我的javascript。它说我的浏览器中未定义变量附件:
var attachments = document.getElementsByName('attachments');
var picCnt = 0;
var resumeCnt = 0;
if(document.getElementsByName('attachments').length >0){
for(var i = 0; i <= attachments.length; i++){
if(attachments[i].value.substring(attachments[i].value.length-4, attachments[i].value.length) == ".doc" ||
attachments[i].value.substring(attachments[i].value.length-5, attachments[i].value.length) == ".docx" ||
attachments[i].value.substring(attachments[i].value.length-4, attachments[i].value.length) == ".pdf" ){
resumeCnt += 1;
}
}
}
这是不正确的吗?蒂亚!