zubama
asked on
how to send multiple data from popup window to main.asp using javacript/vbscript?
<html><head><title>Main</t itle>
<script language=javascript>
function OpenCalculator() {
newdata = window.showModalDialog('2. htm','','d ialogWidth :300px;dia logHeight: 175px;help :No;resiza ble:No;sta tus:No;cen ter:yes' );
}</script>
</head> <body><center>
<font color=red>Copy data from popup page<br>
<input type=text name=A size=3 readOnly onclick ="OpenCalculator();" style="cursor:hand">
<input type=text name=B size=3 readOnly ><input type=text name=C size=3 readOnly >
<input type=text name=D size=3 readOnly ><input type=text name=E size=3 readOnly >
</body> </html>
========================== ========== ========
<html><head><title>New Page 2</title></head>
<body><center>
Send data from this page to Main<br>
<input type=text name=A1 size=3 ><input type=text name=B1 size=3 >
<input type=text name=C1 size=3 ><input type=text name=D1 size=3 >
<input type=text name=E1 size=3 ><br>
<input type=button name=DT value=press>
</body></html>
<script language=javascript>
function OpenCalculator() {
newdata = window.showModalDialog('2.
}</script>
</head> <body><center>
<font color=red>Copy data from popup page<br>
<input type=text name=A size=3 readOnly onclick ="OpenCalculator();" style="cursor:hand">
<input type=text name=B size=3 readOnly ><input type=text name=C size=3 readOnly >
<input type=text name=D size=3 readOnly ><input type=text name=E size=3 readOnly >
</body> </html>
==========================
<html><head><title>New Page 2</title></head>
<body><center>
Send data from this page to Main<br>
<input type=text name=A1 size=3 ><input type=text name=B1 size=3 >
<input type=text name=C1 size=3 ><input type=text name=D1 size=3 >
<input type=text name=E1 size=3 ><br>
<input type=button name=DT value=press>
</body></html>
Hello,
you can send some data by javascript to your parent window
for this, you need to add a reference to the opener in the showModalDialog call
newdata = window.showModalDialog('2. html', self,'dialogWidth:300px;di alogHeight :175px;hel p:No;resiz able:No;st atus:No;ce nter:yes' );
(just replaced '' by self)
Then, in the popup dialog, add the following function
<script language=javascript>
function CloseCalculator() {
var opener = window.dialogArguments;
opener.A.value=A1.value;
....
opener.E.value=E1.value;
window.close();
}</script>
Full script below
you can send some data by javascript to your parent window
for this, you need to add a reference to the opener in the showModalDialog call
newdata = window.showModalDialog('2.
(just replaced '' by self)
Then, in the popup dialog, add the following function
<script language=javascript>
function CloseCalculator() {
var opener = window.dialogArguments;
opener.A.value=A1.value;
....
opener.E.value=E1.value;
window.close();
}</script>
Full script below
<!-- main.htm -->
<html><head><title>Main</title>
<script language=javascript>
function OpenCalculator() {
window.showModalDialog('2.htm', self,'dialogWidth:300px;dialogHeight:175px;help:No;resizable:No;status:No;center:yes' );
}
</script>
</head> <body><center>
<font color=red>Copy data from popup page<br>
<input type=text name=A size=3 readOnly onclick ="OpenCalculator();" style="cursor:hand">
<input type=text name=B size=3 readOnly ><input type=text name=C size=3 readOnly >
<input type=text name=D size=3 readOnly ><input type=text name=E size=3 readOnly >
</body> </html>
<!-- 2.htm -->
<html><head><title>New Page 2</title>
<script language=javascript>
function CloseCalculator() {
var opener = window.dialogArguments;
opener.A.value=A1.value;
opener.B.value=B1.value;
opener.C.value=C1.value;
opener.D.value=D1.value;
opener.E.value=E1.value;
window.close();
}</script></head>
<body ><center>
Send data from this page to Main<br>
<input type=text name=A1 size=3 ><input type=text name=B1 size=3 >
<input type=text name=C1 size=3 ><input type=text name=D1 size=3 >
<input type=text name=E1 size=3 ><br>
<input type=button name=DT onclick ="javascript:CloseCalculator();" value=press>
</body></html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://onwebdevelopment.blogspot.com/2008/06/javascript-cross-window-communication.html