用模式子窗口对父窗口进行赋值
用模式子窗口对父窗口
父窗口的代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Parent Webform </title>
<script language="javascript" >
function OpenChild()
{
var ParmA = retvalA.value;
var ParmB = retvalB.value;
var ParmC = retvalC.value;
var MyArgs = new Array(ParmA, ParmB, ParmC);
var WinSettings = "center:yes;resizable:no;dialogHeight:300px "
//ALTER BELOW LINE - supply correct URL for Child Form
var MyArgs = window.showModalDialog(
"b.html", MyArgs, WinSettings);
if (MyArgs == null)
{
window.alert(
"Nothing returned from child. No changes made to input boxes ")
}
else
{
retvalA.value =MyArgs[0].toString();
retvalB.value =MyArgs[1].toString();
retvalC.value =MyArgs[2].toString();
}
}
</script>
</HEAD>
<body>
<P><INPUT id="retvalA" type="text" value="AAA"></P>
<P><INPUT id="retvalB" type="text" value="BBB"></P>
<P><INPUT id="retvalC" type="text" value="CCC"></P>
<P><BUTTON onclick="OpenChild()" type="button">
Open Child Window </BUTTON>
</P>
</body>
</HTML>
<HTML>
<HEAD>
<title>Parent Web
<script language="javascri
function OpenChild
var ParmA = retvalA.v
//ALTER BELO
var MyArgs = window.sh
{
wi
}
else
{
re
re
re
}
}
</script>
</HEAD>
<body>
<P><INPUT id="retvalA"
<P><INPUT id="retvalB"
<P><INPUT id="retvalC"
<P><BUTTON onclick="OpenChil
</P>
</body>
</HTML>
模式子窗口代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<TITLE>Child Webform </TITLE>
<script language="javascript" >
function Done() {
var ParmA = tbParamA.value;
var ParmB = tbParamB.value;
var ParmC = tbParamC.value;
var MyArgs = new Array(ParmA, ParmB, ParmC);
window.returnValue = MyArgs;
window.close();
}
function doInit() {
var ParmA = "Aparm";
var ParmB = "Bparm";
var ParmC = "Cparm";
var MyArgs = new Array(ParmA, ParmB, ParmC);
MyArgs = window.dialogArguments;
tbParamA.value = MyArgs[0].toString();
tbParamB.value = MyArgs[1].toString();
tbParamC.value = MyArgs[2].toString();
}
</script>
</HEAD>
<BODY onload="doInit()" >
<P>Param A:<INPUT id="tbParamA" TYPE="text"></P>
<P>Param B:<INPUT ID="tbParamB" TYPE="text"></P>
<P>Param C:<INPUT ID="tbParamC" TYPE="text"></P>
<BUTTON onclick="Done()" type="button">OK</BUTTON>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>Child Webf
<script language="javascri
function Done() {
var ParmA = tbParamA.
window
window
}
function doInit()
var ParmA = "Aparm";
var ParmB = "Bparm";
var ParmC = "Cparm";
var MyArgs = new Array(Par
MyArgs
tbPara
tbPara
tbPara
}
</script>
</HEAD>
<BODY onload="doInit()
<P>Param A:<INPUT id="tbParamA
<P>Param B:<INPUT ID="tbParamB
<P>Param C:<INPUT ID="tbParamC
<BUTTON onclick="Done()" type="button">OK</BUTTON>
</BODY>
</HTML>