1

我想提交一个表单弹出窗口。

父.html

<form class="myform" name="forms" onsubmit="return submit_form()" >

</form>
<form class="myform" name="forms" >

</form>
<form class="myform" name="forms" >

</form>

Parent.html JAVASCRIPT

<script>

function submit_form()
{

console.log(0);
return false;
}

window.onload = function(){


//attach eventListner

 document.getElementsByName("forms").addEventListner("submit",function(){

  console.log(1);

  return false;

 },false);


//IN JQUERY 


$(document).ready(function(){

  $(".myform").live("submit",function(){

    console.log(2);return false;

  });

});


};


</script>

我正在使用window.open方法打开一个新的弹出窗口,

我正在尝试从弹出窗口提交表单,如下所示...

var docs = window.opener.document ;


//first try to submit through jQuery

$(docs).find("form").eq(0).submit(); // it will work all browsers except IE8

or

docs.getElementsByTagName("form")[0].submit(); // it will work everywhere ,but on parent window the form will submitted by default (no attached events will work) 

请帮忙 ..

谢谢。

4

1 回答 1

0
div id="divform">
            <form action="/system/wpacert" method="post" enctype="multipart/form-data" name="certform">
                <div>Certificate 1: <input type="file" name="cert1"/></div>
                <div>Certificate 2: <input type="file" name="cert2"/></div>

                <div><input type="button" value="Upload" onclick="closeSelf();"/></div>
            </form>
        </div>
        <div  id="closelink" style="display:none">
            <a href="javascript:window.close()">Click Here to Close this Page</a>
        </div>

function closeSelf(){
    document.forms['certform'].submit();
    hide(document.getElementById('divform'));
    unHide(document.getElementById('closelink'));

}
于 2013-01-10T07:39:44.333 回答