Solved

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

Posted on 2008-06-26
3
562 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
Comment Utility
0
 
LVL 2

Expert Comment

by:pvialatte
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

772 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

10 Experts available now in Live!

Get 1:1 Help Now