Javascript 多文件上传/提交表单
我有一个页面,有多个文件上传表单。它们是在循环中生成的 问题:第一个文件上传控件工作,其余的不工作Javascript 多文件上传/提交表单,javascript,html,Javascript,Html,我有一个页面,有多个文件上传表单。它们是在循环中生成的 问题:第一个文件上传控件工作,其余的不工作 <div> <form action="/docs/1046/UploadDocument?Id=1046&propertyTypeId=1" enctype="multipart/form-data" method="post"> <input name="X-HTTP-Method-Override" type="hidde
<div>
<form action="/docs/1046/UploadDocument?Id=1046&propertyTypeId=1" enctype="multipart/form-data" method="post">
<input name="X-HTTP-Method-Override" type="hidden" value="PUT">
<div style="display: none">
<label for="fileCOMMERCIAL_TRANSPORT_LICENSE"></label>
<input id="fileCOMMERCIAL_TRANSPORT_LICENSE" name="fileCOMMERCIAL_TRANSPORT_LICENSE" type="file" onchange=" $('#btnSubmitData').click(); ">
<input id="btnSubmitData" type="submit" onclick=" txt = $('#fileCOMMERCIAL_TRANSPORT_LICENSE').val(); alert(txt); ">
</div>
<div>
<label>
Document 1:
</label>
<button type="button" onclick=" $('#fileCOMMERCIAL_TRANSPORT_LICENSE').click(); ">Upload 1</button>
</div>
</form>
<form action="/docs/1046/UploadDocument?Id=1046&propertyTypeId=5" enctype="multipart/form-data" method="post">
<input name="X-HTTP-Method-Override" type="hidden" value="PUT">
<div style="display: none">
<label for="fileCLEAN_CRIMINAL_RECORD"></label>
<input id="fileCLEAN_CRIMINAL_RECORD" name="fileCLEAN_CRIMINAL_RECORD" type="file" onchange=" $('#btnSubmitData').click(); ">
<input id="btnSubmitData" type="submit" onclick=" txt = $('#fileCLEAN_CRIMINAL_RECORD').val(); alert(txt); ">
</div>
<div>
<label>
Document 2:
</label>
<button type="button" onclick=" $('#fileCLEAN_CRIMINAL_RECORD').click(); ">Upload 2</button>
</div>
</form>
</div>
文件1:
上传1
文件2:
上传2
:我不知道你的问题是什么,但有时要确保你输入的内容有不同的名称
<form action="...">
<input type="file" name="firstFile" /> //other names
<input type="file" name="secondFile" />
<input type="submit" value="send" />
</form>
//其他名称
使您的id#btnSubmitData唯一。这应该可以解决问题。小提琴在。OP需要编辑他们的帖子并包含代码(不仅仅是链接)。我在你的html代码中没有看到任何错误