Multiple values are transferred between modal windows.

Source: Internet
Author: User
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:

&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;<br>&lt;HTML&gt;<br>    &lt;HEAD&gt;<br>        &lt;title&gt;Parent Webform&lt;/title&gt;<br>        &lt;script language="javascript"&gt;<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>        &lt;/script&gt;<br>    &lt;/HEAD&gt;<br>    &lt;body&gt;<br>        &lt;P&gt;&lt;INPUT id="retvalA" type="text" value="AAA"&gt;&lt;/P&gt;<br>        &lt;P&gt;&lt;INPUT id="retvalB" type="text" value="BBB"&gt;&lt;/P&gt;<br>        &lt;P&gt;&lt;INPUT id="retvalC" type="text" value="CCC"&gt;&lt;/P&gt;<br>        &lt;P&gt;&lt;BUTTON onclick="OpenChild()" type="button"&gt;<br>                Open Child Window&lt;/BUTTON&gt;<br>        &lt;/P&gt;<br>    &lt;/body&gt;<br>&lt;/HTML&gt;

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>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.