Call between parent form and child form-use modal form to pass multiple values

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 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

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.