HTML
  Home arrow HTML arrow More Tricks with Web Page Dialog Boxes
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

More Tricks with Web Page Dialog Boxes
By: Chrysanthus Forcha
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-01-20

    Table of Contents:
  • More Tricks with Web Page Dialog Boxes
  • Parent Table
  • Already Prepared Dialog Boxes
  • Executing a Function in Another Window
  • Accessing Value in an Ancestor Window

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    More Tricks with Web Page Dialog Boxes


    (Page 1 of 5 )

    In this fourth part of a five-part series that details some of the things you can do with web page dialog boxes, you will learn how to change and add content to the immediate parent box, add a row to a parent dialog box, and much more.

    Changing and Adding Content to the Immediate Parent Box

    Recall that the object window in JavaScript represents the current window; that is the window that has the script. We saw that in order to open (create) a child window, we need it; we need to follow it with the dot and the “open()”method. This action returns a reference, which we have been calling “myWindow.” We have been using this reference to access the immediate child window.

    We need a reference to refer to the immediate parent window. The DOM window object has a property called “opener.” This is used to return a reference to the immediate parent window. Consider the following statement.


    var myParent = window.opener;


    The phrase “window.opener” in the statement returns the reference to the immediate parent window. This reference is assigned to the variable “myParent.”

    This is how we shall be accessing the parent window in this series.

    Setting and Reading the Parent JavaScript Variable

    Assume that in the Parent window you have the following JavaScript code:


    <script type="text/javascript">

    var lastName;

    //the rest of the JavaScript code …

    </script>


    From the JavaScript of the child window, you can set this parent variable. giving the value “Smith” as follows:


    myParent = window.opener;

    myParent.lastName = "Smith";


    So, in the JavaScript in the child, you use the reference of the parent window; this is followed by the dot and the variable in the parent window. The value (Smith) for the variable is assigned with the equal sign.

    The following code in the JavaScript of the child window will read the value of the variable of the parent window and assign it to the variable, name, in the child.


    myParent = window.opener;

    var name = myParent.lastName;


    Note that we have been starting with the first statement, which is “myParent = window.opener.” You write the first statement only once within a scope. You can then use the parent reference as many times as you want within the scope. Otherwise you would need to write the following each time you need the reference to the immediate parent:


    window.opener


    With this, to obtain the above name, you would write:


    var name = window.opener.lastName;


    We shall not use this approach in this series. We shall be using the parent reference.

    Setting and Reading Parent Element Values

    In the JavaScript of the child window, the following statement would access the value of an element in the parent window:


    myParent.document.getElementById('I1').value


    Assume that you have the following element in the immediate parent window:


    <input type=”text” id=”I1”>


    The following statement in the child script (window) would set the value of the Input Text Control to “I love you.”


    myParent.document.getElementById('I1').value = "I love you.”;


    And the following code in the child script would read the value of the Input Text control from the parent window into the name variable in the child window:


    var name = myParent.document.getElementById('I1').value;


    More HTML Articles
    More By Chrysanthus Forcha


     

    HTML ARTICLES

    - Comparing Browser Response to Active Client ...
    - Testing Browser Response to Active Client Pa...
    - Active Client Pages: Completing the Code for...
    - ACP and Browsers: Setting up an Example
    - How Browsers Respond to Active Client Pages
    - Completing a Tree with Active Client Pages
    - HTML Form Verification and ACP
    - Building an ACP Tree
    - Completing an ACP 3D HTML Table Image Gallery
    - Building an ACP 3D HTML Table Image Gallery
    - A Multiple Page Image Gallery with Active Cl...
    - Building an Image Gallery with Active Client...
    - Concluding a Menu for All Browsers
    - A Vertical Menu for All Browsers
    - Downloading Long HTML Pages with ACP







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek