Solved

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Javascript 2 22
send email part1 9 27
MS SQL 2008 and stored prodcures and dates 5 12
CSS Style Effect 2 7
This article discusses how to create an extensible mechanism for linked drop downs.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
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 …

856 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