In a web application, how to open a subwindow in a modal window and pass multiple values to the subwindow is acceptable in the subwindow, after modifying these values, can I submit them to the parent window? In codeproject, there is an article about the method, which is described as follows:
1. First create a parent window named parent.html, and write the following HTML code:
<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"
VaR myargs = Window. showmodaldialog (
"Child.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 = "valuea"> </P>
<P> <input id = "retvalb" type = "text" value = "valueb"> </P>
<P> <input id = "retvalc" type = "text" value = "valuec"> </P>
<P> <button onclick = "openchild ()" type = "button">
Open Child Window </button>
</P>
</Body>
</Html>
2. Create a form named child.html and write the following HTML code:
<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 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>
Article Source: http://www.diybl.com/course/4_webprogram/asp.net/netjs/2008917/143223.html