469,572 Members | 1,629 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

passing variables between two different windows

Hello. I'm a rookie ASP VBScripter and am having a difficult time scripting
the following scenario:

I have an index.asp file that has a multi-line text box and a button of type
button. When the button is clicked a window is spawned with change.asp as
its source. There is a form with a few text boxes and with a button of type
submit and a cancel button of type button that just closes the window. What
I want to happen is I want the information entered in change.asp to be added
into the multi-line text box in index.asp when the submit button is clicked
in change.asp. Here are the index.asp and change.asp files:

//-----index.asp------------
<html>
<head>
<title>Product Listing</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<script language="JavaScript" type="text/javascript">
self.moveTo(0,0);
self.resizeTo(screen.availWidth,screen.availHeight );
function changeInfo()
{
var x = (screen.width - 400) / 2;
var y = (screen.height - 320) / 2;
var myWin = window.open("change.asp",null,"scrollbars=no, toolbar=no,
resizable=no, width=400, height=300, left="+x+" top="+y)
}
</script>

<body>
<table width="554" cellpadding="5">
<tr>
<td width="400"><img src="images/HouseValue 031.jpg" width="400"
height="300"></td>
<td width="3027" valign="top"><form name = "picInfo" id = "picInfo">
<textarea name="txtInfo" id="txtInfo" cols="40" rows="10"
wrap="soft" readonly>Press "Change" to enter information.</textarea>
<br>
<input type="button" value="Change" id="btnChange" name="btnChange"
onClick="javascript:changeInfo()">
</form></td>
</tr>
</table>
</body>
</html>
//-----------------------------------
//-------change.asp-----------------
<html>
<head>
<title>Edit Product Description</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="JavaScript" type="text/javascript">
function Cancel()
{
window.close();
}
</script>
<body>
<form name="frmChange" id="frmChange" method="post">
<table>
<tr>
<td align="right">Product Name:</td>
<td align="left"><input type="text" name="txtProduct" id="txtProduct"
size="40"></td>
</tr>
<tr>
<td align="right">Model #:</td>
<td align="left"><input type="text" name="txtModel" id="txtModel"
size="40"></td>
</tr>
<tr>
<td align="right">Value:</td>
<td align="left"><input type="text" name="txtValue" id="txtValue"></td>
</tr>
<tr>
<td align="right">Category:</td>
<td align="left"><select name="mnuCategory" id="mnuCategory">
<option selected value="NULL">Choose category...</option>
<option value="Furniture">Furniture</option>
<option value="Electronics">Electronics</option>
<option value="Home Media">Home Media</option>
<option value="Jewlery">Jewlery</option>
</select></td>
</tr>
<tr>
<td align="right" valign="top">Misc. Information:</td>
<td align="left"><textarea name="txtMisc" id="txtMisc" cols="30"
rows="5"></textarea></td>
</tr>
</table>
<br>
<center>
<input type="submit" name="btnSubmitChanges" id="btnSubmitChanges"
value="Submit">
<input type="button" name="btnCancel" id="btnCancel" value="Cancel"
onClick="javascript:Cancel()">
</center>
</form>
</body>
</html>
//-------------------------

I've been messing with it for a day now and I have been unable to pass
variables from change.asp into index.asp. Any help would be much
appreciated.

~Les Peabody
Nov 18 '05 #1
2 1623
Sounds like you'll be needing to use some client side javascript.
You can open a new window using javascript such as this:
a=window.open('MyPage.aspx','_new')
There are all kinds of options for setting window properties such as window
size and toolbar visibility.
Here's more info:
http://msdn.microsoft.com/workshop/a...ods/open_0.asp

From that new window you can reference the original parent window with
this javascript reference:

Here's an example:
window.opener.document.form1.mytextbox.value = 'whatever';

Here's more info:
http://www.mozilla.org/docs/dom/domr...dow_ref77.html

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com
"Les Peabody" <le*********@geo-sync.com> wrote in message
news:eG**************@TK2MSFTNGP10.phx.gbl...
Hello. I'm a rookie ASP VBScripter and am having a difficult time scripting the following scenario:

I have an index.asp file that has a multi-line text box and a button of type button. When the button is clicked a window is spawned with change.asp as
its source. There is a form with a few text boxes and with a button of type submit and a cancel button of type button that just closes the window. What I want to happen is I want the information entered in change.asp to be added into the multi-line text box in index.asp when the submit button is clicked in change.asp. Here are the index.asp and change.asp files:

//-----index.asp------------
<html>
<head>
<title>Product Listing</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<script language="JavaScript" type="text/javascript">
self.moveTo(0,0);
self.resizeTo(screen.availWidth,screen.availHeight );
function changeInfo()
{
var x = (screen.width - 400) / 2;
var y = (screen.height - 320) / 2;
var myWin = window.open("change.asp",null,"scrollbars=no, toolbar=no,
resizable=no, width=400, height=300, left="+x+" top="+y)
}
</script>

<body>
<table width="554" cellpadding="5">
<tr>
<td width="400"><img src="images/HouseValue 031.jpg" width="400"
height="300"></td>
<td width="3027" valign="top"><form name = "picInfo" id = "picInfo">
<textarea name="txtInfo" id="txtInfo" cols="40" rows="10"
wrap="soft" readonly>Press "Change" to enter information.</textarea>
<br>
<input type="button" value="Change" id="btnChange" name="btnChange"
onClick="javascript:changeInfo()">
</form></td>
</tr>
</table>
</body>
</html>
//-----------------------------------
//-------change.asp-----------------
<html>
<head>
<title>Edit Product Description</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="JavaScript" type="text/javascript">
function Cancel()
{
window.close();
}
</script>
<body>
<form name="frmChange" id="frmChange" method="post">
<table>
<tr>
<td align="right">Product Name:</td>
<td align="left"><input type="text" name="txtProduct" id="txtProduct"
size="40"></td>
</tr>
<tr>
<td align="right">Model #:</td>
<td align="left"><input type="text" name="txtModel" id="txtModel"
size="40"></td>
</tr>
<tr>
<td align="right">Value:</td>
<td align="left"><input type="text" name="txtValue" id="txtValue"></td>
</tr>
<tr>
<td align="right">Category:</td>
<td align="left"><select name="mnuCategory" id="mnuCategory">
<option selected value="NULL">Choose category...</option>
<option value="Furniture">Furniture</option>
<option value="Electronics">Electronics</option>
<option value="Home Media">Home Media</option>
<option value="Jewlery">Jewlery</option>
</select></td>
</tr>
<tr>
<td align="right" valign="top">Misc. Information:</td>
<td align="left"><textarea name="txtMisc" id="txtMisc" cols="30"
rows="5"></textarea></td>
</tr>
</table>
<br>
<center>
<input type="submit" name="btnSubmitChanges" id="btnSubmitChanges"
value="Submit">
<input type="button" name="btnCancel" id="btnCancel" value="Cancel"
onClick="javascript:Cancel()">
</center>
</form>
</body>
</html>
//-------------------------

I've been messing with it for a day now and I have been unable to pass
variables from change.asp into index.asp. Any help would be much
appreciated.

~Les Peabody

Nov 18 '05 #2
That worked great, I figured there would be a way to access the parent
window. Thanks Steve.

~Les Peabody

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Sounds like you'll be needing to use some client side javascript.
You can open a new window using javascript such as this:
a=window.open('MyPage.aspx','_new')
There are all kinds of options for setting window properties such as window size and toolbar visibility.
Here's more info:
http://msdn.microsoft.com/workshop/a...ods/open_0.asp
From that new window you can reference the original parent window with
this javascript reference:

Here's an example:
window.opener.document.form1.mytextbox.value = 'whatever';

Here's more info:
http://www.mozilla.org/docs/dom/domr...dow_ref77.html

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com
"Les Peabody" <le*********@geo-sync.com> wrote in message
news:eG**************@TK2MSFTNGP10.phx.gbl...
Hello. I'm a rookie ASP VBScripter and am having a difficult time

scripting
the following scenario:

I have an index.asp file that has a multi-line text box and a button of

type
button. When the button is clicked a window is spawned with change.asp as its source. There is a form with a few text boxes and with a button of

type
submit and a cancel button of type button that just closes the window.

What
I want to happen is I want the information entered in change.asp to be

added
into the multi-line text box in index.asp when the submit button is

clicked
in change.asp. Here are the index.asp and change.asp files:

//-----index.asp------------
<html>
<head>
<title>Product Listing</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<script language="JavaScript" type="text/javascript">
self.moveTo(0,0);
self.resizeTo(screen.availWidth,screen.availHeight );
function changeInfo()
{
var x = (screen.width - 400) / 2;
var y = (screen.height - 320) / 2;
var myWin = window.open("change.asp",null,"scrollbars=no, toolbar=no,
resizable=no, width=400, height=300, left="+x+" top="+y)
}
</script>

<body>
<table width="554" cellpadding="5">
<tr>
<td width="400"><img src="images/HouseValue 031.jpg" width="400"
height="300"></td>
<td width="3027" valign="top"><form name = "picInfo" id = "picInfo">
<textarea name="txtInfo" id="txtInfo" cols="40" rows="10"
wrap="soft" readonly>Press "Change" to enter information.</textarea>
<br>
<input type="button" value="Change" id="btnChange" name="btnChange"
onClick="javascript:changeInfo()">
</form></td>
</tr>
</table>
</body>
</html>
//-----------------------------------
//-------change.asp-----------------
<html>
<head>
<title>Edit Product Description</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="JavaScript" type="text/javascript">
function Cancel()
{
window.close();
}
</script>
<body>
<form name="frmChange" id="frmChange" method="post">
<table>
<tr>
<td align="right">Product Name:</td>
<td align="left"><input type="text" name="txtProduct" id="txtProduct"
size="40"></td>
</tr>
<tr>
<td align="right">Model #:</td>
<td align="left"><input type="text" name="txtModel" id="txtModel"
size="40"></td>
</tr>
<tr>
<td align="right">Value:</td>
<td align="left"><input type="text" name="txtValue" id="txtValue"></td>
</tr>
<tr>
<td align="right">Category:</td>
<td align="left"><select name="mnuCategory" id="mnuCategory">
<option selected value="NULL">Choose category...</option>
<option value="Furniture">Furniture</option>
<option value="Electronics">Electronics</option>
<option value="Home Media">Home Media</option>
<option value="Jewlery">Jewlery</option>
</select></td>
</tr>
<tr>
<td align="right" valign="top">Misc. Information:</td>
<td align="left"><textarea name="txtMisc" id="txtMisc" cols="30"
rows="5"></textarea></td>
</tr>
</table>
<br>
<center>
<input type="submit" name="btnSubmitChanges" id="btnSubmitChanges"
value="Submit">
<input type="button" name="btnCancel" id="btnCancel" value="Cancel"
onClick="javascript:Cancel()">
</center>
</form>
</body>
</html>
//-------------------------

I've been messing with it for a day now and I have been unable to pass
variables from change.asp into index.asp. Any help would be much
appreciated.

~Les Peabody


Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Consuelo Guenther | last post: by
reply views Thread by Chris Zoper | last post: by
7 posts views Thread by Khai | last post: by
2 posts views Thread by Hakan Örnek | last post: by
7 posts views Thread by Cordouan | last post: by
6 posts views Thread by coool | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.