Link to home
Start Free TrialLog in
Avatar of zubama
zubamaFlag for United States of America

asked on

how to send multiple data from popup window to main.asp using javacript/vbscript?

<html><head><title>Main</title>
<script language=javascript>
function OpenCalculator() {
newdata = window.showModalDialog('2.htm','','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>
============================================
<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>
Avatar of Dauhee
Dauhee
Flag of Ireland image

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;dialogHeight:175px;help:No;resizable:No;status:No;center: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


<!-- 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>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of zubama
zubama
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial