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 parentwebform, and write the following HTML code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><br><HTML><br> <HEAD><br> <title>Parent Webform</title><br> <script language="javascript"><br>function OpenChild() <br>{<br> var ParmA = retvalA.value;<br> var ParmB = retvalB.value;<br> var ParmC = retvalC.value;<br> var MyArgs = new Array(ParmA, ParmB, ParmC);<br> var WinSettings = "center:yes;resizable:no;dialogHeight:300px"<br> //ALTER BELOW LINE - supply correct URL for Child Form<br> var MyArgs = window.showModalDialog(<br> "http://localhost/ModalWin/ChildWebForm.aspx", MyArgs, WinSettings);<br> if (MyArgs == null)<br> {<br> window.alert(<br> "Nothing returned from child. No changes made to input boxes")<br> }<br> else<br> {<br> retvalA.value=MyArgs[0].toString();<br> retvalB.value=MyArgs[1].toString();<br> retvalC.value=MyArgs[2].toString();<br> }<br>}<br> </script><br> </HEAD><br> <body><br> <P><INPUT id="retvalA" type="text" value="AAA"></P><br> <P><INPUT id="retvalB" type="text" value="BBB"></P><br> <P><INPUT id="retvalC" type="text" value="CCC"></P><br> <P><BUTTON onclick="OpenChild()" type="button"><br> Open Child Window</BUTTON><br> </P><br> </body><br></HTML> |
2. Create a form named childwebform and write the following HTML code:
<! 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>