以下文件在浏览器兼容模式下点击“添加”,“删除”按钮能够很好地添加或删除一行,
但是在快速模式下,点击“添加”或“删除”后就好像自动点击了“文件上传”按钮。
为何这样,无法理解,求助于各位大侠解惑。
FileUpLoad <script> <br /> <br /> function findObj(theObj, theDoc) <br /> { <br /> var p, i, foundObj; <br /> if(!theDoc) theDoc = document; <br /> if( (p = theObj.indexOf("?")) > 0 && parent.frames.length) <br /> { <br /> theDoc = parent.frames[theObj.substring(p+1)].document; <br /> theObj = theObj.substring(0,p); <br /> } <br /> if(!(foundObj = theDoc[theObj]) && theDoc.all) <br /> foundObj = theDoc.all[theObj]; <br /> for (i=0; !foundObj && i < theDoc.forms.length; i++) <br /> foundObj = theDoc.forms[i][theObj]; <br /> for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) <br /> foundObj = findObj(theObj,theDoc.layers[i].document); <br /> if(!foundObj && document.getElementById) <br /> foundObj = document.getElementById(theObj); <br /> return foundObj; <br /> } <br /> function delRow() <br /> { <br /> var bt_filesum = findObj("bt_filesum",document); <br /> var filesum = parseInt(bt_filesum.value); <br /> <br /> if (filesum<=1) <br /> { <br /> alert('上传文件数最小为1,删除无效'); <br /> } <br /> else <br /> { <br /> var signFrame = findObj("SignFrame",document); <br /> signFrame.deleteRow(filesum-1); <br /> <br /> bt_filesum.value = (filesum-1).toString() ; <br /> } <br /> } <br /> function addRow() <br /> { <br /> var bt_filesum = findObj("bt_filesum",document); <br /> var filesum = parseInt(bt_filesum.value)+1; <br /> <br /> if(filesum>5) <br /> { <br /> alert('一次最多上传5个文件'); <br /> } <br /> else <br /> { <br /> var signFrame = findObj("SignFrame",document); <br /> //添加行 <br /> var newTR = signFrame.insertRow(signFrame.rows.length); <br /> newTR.id = "file_addordel" + filesum; //新行之id属性赋值 <br /> //添加列0:上传文件 <br /> var newTD0=newTR.insertCell(0); <br /> newTD0.align="right"; //列0属性之align <br /> newTD0.innerHTML = "<input type='hidden' name='MAX_FILE_SIZE' value='5000000'/>上传文件"+filesum+":"; <br /> <br /> //添加列:上传文件输入格 <br /> var newTD1=newTR.insertCell(1); <br /> newTD1.innerHTML = "<input type='file' name='file_upload[]' id='file_upload[]'/>" <br /> <br /> //添加列:文件版本 <br /> var newTD2=newTR.insertCell(2); <br /> newTD2.align="right"; <br /> newTD2.innerHTML ="文件版本:"; <br /> <br /> //添加列:文件版本输入 <br /> var newTD3=newTR.insertCell(3); <br /> newTD3.innerHTML ="<input type='text' name='file_ver' value='100'size='8' maxlength='15'/>"; <br /> bt_filesum.value = (filesum).toString() ; <br /> } <br /> } <br /> </script>
Déclaration:Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn