日期:2014-05-17  浏览次数:20656 次

关于form 提交的问题
页面里面两个form的代码:
<form name="form3" method="post" action="me062.jsp?handleType=upload" enctype="multipart/form-data">
<table width="60%" align="center">
<tr class="table-body"> 
<td width="15%" class="columcolor">&nbsp;&nbsp;订单明细</td>
<td width="85%">&nbsp;&nbsp;<input type="file" name="reference11" size="50" contenteditable="false"/></td>
<td colspan="2" align="center">
<input type="button" value="导 入" onclick="aa()">
<input type="reset" value="取 消"/>
</td>
</tr>
  <tr>
  <td>
  <ui:button action ="excuteproceduce" label="执行存储过程"/>
  </td>
  </tr>
</table>
</form>
<form name="form4" method="post" action="me062.jsp?handleType=upload2" enctype="multipart/form-data">
<table width="60%" align="center">
<tr class="table-body"> 
<td width="15%" class="columcolor">发货明细</td>
<td width="85%">&nbsp;&nbsp;<input type="file" name="reference" size="50" contenteditable="false"/></td>
<td colspan="2" align="center">
<input type="button" value="导 入" onclick="bb()">
<input type="reset" value="取 消"/>
</td>
</tr>
  <tr>
  </tr>
</table>
</form>

<script type="text/javascript">
function aa(){
 var obj = document.form3.reference11;
 var array = obj.value.split(".");
 if(array[array.length-1]=="xlsx"){
  document.form3.submit();
 }else{
  alert("导入文件的后缀名必须是xlsx");
  document.form3.reset();
 }
}
function bb(){
 var obj = document.form4.reference;
 var array = obj.value.split(".");
 if(array[array.length-1]=="xlsx"){
  document.form4.submit();
 }else{
  alert("导入文件的后缀名必须是xlsx");
  document.form4.reset();
 }
}
</script>

点击form3 报错:document.form3.reference11为空对象?啥原因啊?高手

------解决方案--------------------
document.form3.reference11

这里的form3以及reference11 都是应该是ID 不是name
------解决方案--------------------
name="reference" 换成 id="reference"试试?
------解决方案--------------------
不知道LZ用的什么浏览器、哪一个版本!
我用IE7测试了一下你的代码、完全木有问题!
------解决方案--------------------
下次 把代码 格式调的好看一些 要注意 规范!
应该是你ID和name的问题

------解决方案--------------------
document.forms["form3"].reference试试