|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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; |
|
#3
|
|||
|
|||
|
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,he ight=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> </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> |
|
#4
|
|||
|
|||
|
<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).] |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > popup window -> get value to main form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|