0
<script type="text/javascript">
function getFile()
   {  
  document.getElementById("image").click();
   }
function sub()
   {  
   document.getElementById("button").click();
   }

</script>

<form action="addexec.php" method="post" enctype="multipart/form-data" name="addroom">
<div id="yourBtn" onclick="getFile()">click to upload a file</div>
<div style='height: 0px; width: 0px;overflow:hidden;'>
<input id="image" type="file" value="image" name='image' onchange="sub()"/></div>
<input id='button' type='submit' />
</form>

我如何直接提交图像,而不是在函数 sub() 中调用提交按钮

4

1 回答 1

1

直接使用以下行提交表单:

document.addroom.submit();
于 2012-12-24T06:22:39.950 回答