Solved

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

Posted on 2008-06-26
3
563 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

914 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now