#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    13
    Rep Power
    0
    I am going to write a code below:

    -opening a popup window for user to choose any one of the 3 choices (using radio button, with button "select").

    -The new window displays the 3 choices and passes the selected choice back to the the main window when press button "select" and display at one text box at main window.

    (p/s: one main window + one pop up window)

    thank you.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 1999
    Posts
    114
    Rep Power
    16
    In the pop-up window, you can refer back to the main window by using:

    self.opener

    So your code might look something like

    self.opener.mainform.my_text_element.value = xxx;
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    13
    Rep Power
    0
    Below is the two html file, can you tell me what problem with this source code, why I can't get the value ?

    --------------------------------
    This is my main form(form.html):
    --------------------------------
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript">
    function windowopener(){
    controlWindow=window.open("window.html","","toolbar=no,location=no,directories=no,status=yes,menubar =no,scrollbars=yes,resizable=no,width=220,height=265");
    }
    </script>
    </head>
    <body bgcolor="#FFFFFF">
    <form name="mainform">
    <p>Vtype
    <select name="vtype">
    <option value="-1" selected>[ Select One ]</option>
    <option value="PC">Private Car</option>
    <option value="T">Taxi</option>
    </select>
    <input type="submit" name="choose" value="Choose" onclick="windowopener()">
    </p>
    <p>CC
    <input type="text" name="cc">
    </p>
    </form>
    <p>&nbsp;</p>
    </body>
    </html>

    -------------------------------------
    This is my pop up window(window.htm):
    -------------------------------------
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body bgcolor="#FFFFFF">
    <script language="JavaScript">
    function getresult(choose){
    self.opener.mainform.cc.value=choose;
    window.close();
    }
    </script>
    <form name="form1" >
    <p>
    <input type="radio" name="choose" value="select1">
    select 1 </p>
    <p>
    <input type="radio" name="choose" value="select2">
    select 2 </p>
    <p>
    <input type="radio" name="choose" value="select3">
    select 3</p>
    <p>
    <input type="submit" name="select" value="select" onclick=getresult(choose)>
    <input type="button" name="close" value="close" onclick="window.close()">
    </p>
    </form>
    </body>
    </html>
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    1
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by asktan:
    Below is the two html file, can you tell me what problem with this source code, why I can't get the value ?

    [/quote]
    In form.html change the type of "choose" from "submit" to "button".

    I am writing the whole window.html here.

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body bgcolor="#FFFFFF">
    <script language="JavaScript">
    function getresult(){
    for(i=0; i<3; i++)
    {
    if(document.forms[0].elements[i].checked)
    {
    var the_value = document.forms[0].elements[i].value;
    }
    }
    self.opener.mainform.cc.value=the_value;
    window.close();
    }
    </script>
    <form name="form1" >
    <p>
    <input type="radio" name="choose" value="select1">
    select 1 </p>
    <p>
    <input type="radio" name="choose" value="select2">
    select 2 </p>
    <p>
    <input type="radio" name="choose" value="select3">
    select 3</p>
    <p>
    <input type="button" name="select" value="select" onclick=getresult()>
    </p>
    </form>
    </body>
    </html>


    [This message has been edited by tanvi (edited June 02, 2000).]

Similar Threads

  1. popup window from a popup window
    By shiggins in forum Java Help
    Replies: 0
    Last Post: October 30th, 2003, 08:53 AM
  2. Replies: 0
    Last Post: September 9th, 2003, 02:13 PM
  3. New window and session_start hanging main window
    By james555 in forum PHP Development
    Replies: 7
    Last Post: August 6th, 2003, 05:08 PM
  4. Replies: 1
    Last Post: May 7th, 2003, 03:49 PM
  5. How to go from PopUp window to Main Screen
    By Robert Trost in forum HTML Programming
    Replies: 5
    Last Post: October 28th, 2001, 04:07 PM

IMN logo majestic logo threadwatch logo seochat tools logo