Javascript sub-parent form value passing

Source: Internet
Author: User
I have two pages. The homepage is add_rz.aspx, And the subpage is open_kh.aspx. In order to realize the subpage value passing to the parent page, I found some implementation methods on the Internet. Later, because the project needs to be modified to two different main forms to share one subform.
Select the selection button in the gridview of the child page, and pass the value to the parent page for display.

Add JavaScript to the parent formCodeAs follows.

<Script language = "JavaScript">

Function choosekh_show (OBJ)
{
Window. open ("openfind_kh.aspx", "xuanze", "width = 800, Height = 600, Top = 20, Left = 200, toolbar = No, menubar = No, scrollbars = Yes, resizable = Yes, location = No, status = No ");
}
</SCRIPT>

"Xuanze" indicates that the window is accessed by a specific name.
Subpage Javascript

Function choose (kind, KH)
{
Try
{
If (window. Parent. Name = "xuanze ")
{
Using Role opener.doc ument. getelementbyid ("ctl00_contentplaceholder1_txtkh"). value = kind;
Optional values opener.doc ument. getelementbyid ("ctl00_contentplaceholder1_txtkhname"). value = KH;

}

Else
{
Optional values opener.doc ument. getelementbyid ("txtkh"). value = kind;
}
}
Catch (e ){}
Window. Close ();
}

The subpage calls Javascript in the rowdatabound event of the gridview.

If (E. Row. rowtype = datacontrolrowtype. datarow)
{
String kind = E. Row. cells [0]. text;
String kh = E. Row. cells [1]. text;
Ch. Attributes. Add ("onclick", "javascript: Choose ('" + kind + "', '" + KH + "');");
}

Parent page

Subpage


Related Article

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.