HTML
  Home arrow HTML arrow Opening Web Page Dialog Boxes with Other D...
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

Opening Web Page Dialog Boxes with Other Dialog Boxes
By: Chrysanthus Forcha
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2009-01-12

    Table of Contents:
  • Opening Web Page Dialog Boxes with Other Dialog Boxes
  • Content
  • Child HTML
  • Adding a Row in a Child Table

  • 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


    Opening Web Page Dialog Boxes with Other Dialog Boxes


    (Page 1 of 4 )

    It is possible for one dialog box to open another dialog box. In this way, you can have a chain of boxes where the box that opens is the Parent box, and the one opened is the Child box. The main window is the first parent. In this article, the third one in a five-part series, you will learn how to do this and more.

    Dialog Box Opening Another Dialog Box

    To make this chain of boxes possible, the string that is the content of the child box should have the complete style and JavaScript code for the child box. For the purpose of maintenance, the string for each box should be an independent string in the code of the main window.

    In the following code, you have a main window which opens a dialog box; the opened dialog box has a button that, when clicked, would open another dialog box.

    <html>

    <head>


    <script type="text/javascript">

    childBoxContent = "<script type="text/javascript">"

    + "function openAnotherBox()"

    + "{"

    + "boxStr2 = "<html>""

    + "+"<head>""

    + "+"<title>""

    + "+"Second Dialog Box""

    + "+"</title>""

    + "+"<style type="text/css">""

    + "+"body {background-color:silver}""

    + "+"</style>""

    + "+"</head>""

    + "+"<body>""

    + "+"First Input: &nbsp&nbsp&nbsp&nbsp&nbsp<input type="text"> <br />""

    + "+"Second Input: <input type="text"> <br /> <br />""

    + "+"<button type="button">Done</button>""

    + "+"</body>""

    +"+"</html>";"


    + "myWindow2 = window.open("","","menubar=no,toolbar=no,width=400,height=400","");"

    + "myWindow2.document.write(boxStr2);"


    + "}"

    + "</script>";

     

    function openWindow()

    {

    boxStr1 = "<html>"

    + "<head>"

    + "<title>"

    + "First Dialog Box"

    + "</title>"

    + "<style type="text/css">"

    + "body {background-color:silver}"

    + "</style>"

    + childBoxContent

    + "</head>"

    + "<body>"

    + "First Input: &nbsp&nbsp&nbsp&nbsp&nbsp<input type="text"> <br />"

    + "Second Input: <input type="text"> <br /> <br />"

    + "<button type="button" onclick="openAnotherBox()">Open Another Box</button> <br /> <br />"

    + "<button type="button">Done</button>"

    + "</body>"

    +"</html>";

     

    myWindow1 = window.open("","","menubar=no,toolbar=no,width=400,height=400","");

    myWindow1.document.write(boxStr1);

    }

    </script>

    </head>

    <body>

    <button type="button" onclick="openWindow()">Click to Open Dialog Box</button>

    </body>

    </html>


    Note the extra escaping and the plus signs of the string for the second dialog box. This is because we are dealing with a string of strings. The string is not meant for the dialog box to be opened; it is meant for the dialog box (second) that will be opened by the opened (first) dialog box.

    A point to note here is the use of the semi-colon at the end of a JavaScript statement that will be in the new window. In the main window, the new window’s content is in a string. The code, as I have given it above, will be in one long line, without the carriage return and new line characters to separate the statements. So if two statements are joined together, they will not be interpreted as such. You need the semi-colon to separate them.

    This approach of creating dialog boxes using strings of strings can be tedious. I will show you an easier way, later in the series.

    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 4 Hosted by Hostway
    Stay green...Green IT