从子窗口提交父窗口表单

时间:2013-01-07 12:11:29

标签: forms jsp popup window struts

我正在显示一个带有一些选择的弹出窗口(子窗口)。一旦用户在子窗口中提交它们,我将这些值传递给父窗口并提交表单。这些值会在没有任何问题的情况下提交给后端。但是,在提交表单时,父窗口不会刷新。

function commonPopup(popup, width, height, e, top, left) {
    myWindow=window.open('about:blank', popup, 'directories=0,scrollbars=yes, resizable=yes, location=0, menubar=0, status=0, toolbar=0, width=' + width + ', height=' + height + ', top=' + top + ', left=' + left);   
    myWindow.document.write('<HEAD>'); 
    myWindow.document.write('   <TITLE>Waiting for results</TITLE>'); 
    myWindow.document.write('</HEAD>');

}
function post_lock_unlock_value(reason,comment) {
    document.getElementById('lockReason').value = reason;
    document.getElementById('lockComment').value = comment;
    document.getElementById('triggerActionId').value='';
    document.getElementById('admRepairLock').submit();
}
<s:form name="lock" id="lock" action="my.action">
    <s:submit value="Lock Repair Profile" id="lockIndicator" name="lockIndicator"
                                                            onclick="commonPopup('lockProfile',450, 200, event,'lockRepairProfile');" cssStyle="width:200px" theme="simple"/>
</s:form>

在子页面

function postback() {  
    window.opener.post_lock_unlock_value("data","data");
    self.close();

}

2 个答案:

答案 0 :(得分:0)

在关闭子窗口之前刷新父像这样(在self.close()之前添加):

if ( window.opener && !window.opener.closed ) {
   window.opener.location.reload();                     
   window.opener.focus();
}

答案 1 :(得分:0)

试试这个:

var newPartyId = $("#desc_textarea").val();
window.opener.$("#desc_textarea").val(newPartyId);