窗口弹出窗口在提交文本时刷新基本文件?

时间:2014-05-12 23:11:25

标签: php

在我的基页index.php中我使用了这个

<a href="#" onclick="MyWindow=window.open('dialog.php?id=<?php echo $id; ?>','MyWindow','width=650,height=600'); return false;" style="color:green;">SHOW</a>

打开一个包含表单的对话框窗口,允许我使用PHP提交一些文本。

Show链接不会更改,您点击它,窗口会打开,并且可能包含一些数据。

当我向dialog.php提交内容时,如何刷新index.php? 我的目标是将数据显示到index.php

谢谢 更新

我将此添加到dialog.php

<script>
    window.onunload = refreshParent;
    function refreshParent() {
        window.opener.location.reload();
    }
</script>

当我关闭窗口时,它会刷新父页面。

有没有办法让它在

时发生
<input type="submit" name="submit" class="button" id="submit_btn" value="ADD">

是否已提交?

1 个答案:

答案 0 :(得分:0)

只需将您的函数refreshParent()添加到提交按钮的onclick事件中。

<input onclick="refreshParent()" type="submit" name="submit" class="button" id="submit_btn" value="ADD">

请注意,使用&#39; onclick&#39;通常不鼓励标签。更好的方法是使用addEventListener

document.getElementById('submit_btn').addEventListener('click', function () {
    refreshParent;
}, false);

或者使用JQuery:

$( "#submit_btn" ).click(function() {
    refreshParent;
});