我的页面是这么写的
<input id="btSave" type=button value="保存" onclick="saveObjectInfo();"><form id="frm1_1" name="frm1_1" method="post" enctype="multipart/form-data" target="ifrIMG">
<input type="file" id="upload"  name="upload">
</form><iframe id="ifrIMG" style="display:none" ></iframe>function saveObjectInfo()
{
   document.getElementById("frm1_1").action="postImg.aspx?id=12";
   document.getElementById("frm1_1").submit();
}我想实现的功能就是
通过提交 from 在postImg.aspx里面把图片存进数据库里面
父页面还有很多东西不止<form id="frm1_1"    
没有一个 服务端的控件。不用服务端控件也是有其他原因的。
我想解决的问题是 提交from 但是不打开页面。
谢谢。

解决方案 »

  1.   

    target要用name
    <iframe id="ifrIMG" name="ifrIMG" style="display:none" ></iframe>
      

  2.   


    <input id="btSave" type=button value="保存" onclick="saveObjectInfo();"><form id="frm1_1" name="frm1_1" method="post" enctype="multipart/form-data" target="_ifrIMG">
    <input type="file" id="upload" name="upload">
    </form>
    <iframe name="_ifrIMG" style="display:none" width="300" height="200" ></iframe>
    <script>function saveObjectInfo()
    {
      document.getElementById("frm1_1").action="http://localhost/mtest.php";
      document.getElementById("frm1_1").submit();
    }
    </script>
      

  3.   

    1楼的方法可以,当然也可以借助ajax实现
    或者模拟个:提交到某个处理页面 然后再返回当前页面
      

  4.   


    有了name 也是会打开页面的
      

  5.   

    还会打开页面就肯定是你的response的页面上有弹出窗口之类的东西了.
      

  6.   

    带file控件的form不能ajax提交,只能模拟。参考cloudgamer大婶的实例