?
Solved

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

Posted on 2008-06-26
3
Medium Priority
?
570 Views
Last Modified: 2008-07-05
<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>
0
Comment
Question by:zubama
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Expert Comment

by:Dauhee
ID: 21877960
0
 
LVL 2

Expert Comment

by:pvialatte
ID: 21882292
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

0
 

Accepted Solution

by:
zubama earned 0 total points
ID: 21882982
I solve the problem. Thanks.
<HTML> <HEAD> <title>WebForm</title>
<script language=javascript>
function PopUp(){
var SelectedValues = document.all("Text1").value + "|" +
document.all("Text2").value + "|" + document.all("Text3").value + "|" +
document.all("Text4").value + "|" + document.all("Text5").value
var Newdate = window.showModalDialog("PopUp.htm?parm="+SelectedValues, '','status:No;");
if (Newdate!=undefined) {      var x = Newdate.split('|'); document.all("Text1").value = x[0];
document.all("Text2").value = x[1]; document.all("Text3").value = x[2]; document.all("Text4").value = x[3];
document.all("Text5").value = x[4]; }  
}  </script> </HEAD>
 <body> <form id="Form1" method="post" runat="server">
<INPUT type=text size=4 name=Text1><INPUT type=text size=4 name=Text5><INPUT type=text size=5 name=Text4><INPUT type=text size=4 name=Text3 ><INPUT type=text size=2 name=Text2>
<INPUT type=button value=Button name=Button1 onclick="PopUp();">
 </form> </body></HTML>
======================================================
<HTML><HEAD><title>PopUp</title>
<script language=javascript>
function CloseMe()   {
var SelectedValues = document.all("Text1").value + "|" +
document.all("Text2").value + "|" + document.all("Text3").value + "|" +
document.all("Text4").value + "|" + document.all("Text5").value
window.returnValue=SelectedValues; window.self.close(); }
</script></HEAD>
<body><form method="post"><INPUT type=text name=Text1><INPUT type=text name=Text5><INPUT type=text name=Text4 ><INPUT type=text name=Text3><INPUT type=text name=Text2><INPUT type=button value=Button name=Button1 onclick=CloseMe();></form></body></HTML>
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question