我在A窗口中采用一个一对多的信息列表:如在上面列出学校信息,然后在下端采用表格的方式列出各个班级的信息,现在我想通过点击一个按钮打开一个新窗口B,在B中输入详细的班级信息保存后。点击B窗口的按钮来关闭B窗口同时更新A窗口中的班级列表的记录信息。我想问的是:B窗口的关闭按钮的方法该怎么写??,分不够可以加。请大家帮忙。
parent.htm:
<html>
<body>
<input type="Text" name="tt" value="parent">
<br>
<input type="button" name="go" value="Go" onclick="Test()" ID="Button1">
<script language="javascript">
function Test()
{
window.open("tChild.htm");
}
</script>
</body>
</html>
window.opener.document.all.Button1.click();
关闭窗体并刷新父页:
<script language=javascript>
window.opener.location.reload();
window.close();
</script>
>>>同时更新A窗口中的班级列表的记录信息?
how are you planning to do that? if you plan to refresh the information from the database, then you could try the following:
1. if you use window.open() to open a new window, you can do in javascript
<script language="javascript">
function window.onunload()
{
window.opener.document.all("BUTTON1").click();
window.close();
}
</script>
2. if you use window.showModalDialog(), then upon returning from the dialog
<script language="javascript">
var ret = window.showModalDialog(.....);
document.all("BUTTON1").click();
</script>
对“不过我的目的是保留选定的学校信息,更新学校下面的班级信息列表内容”表达不明,意思不清晰。
如果我没理解错的话,应该这样做:
在打开子窗口时把你选定的学校信息作为参数传过去,
如:window.open("child.aspx?schoolname=" & schoolname)
,
然后在子窗口保存后,加上代码window.opener.location="parent.aspx?schoolname=" +schoolname
在父窗口得到schoolname后,就可以显示之前选定的学校信息和下面的班级信息列表内容。
提供一种思路:
在关闭事件里加入将数据保存回数据库的代码.
在主窗口的刷新事件里加入重新绑定数据的代码.