passing variables between two different windows

L

Les Peabody

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
 
S

Steve C. Orr [MVP, MCSD]

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/author/dhtml/reference/methods/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/domref/dom_window_ref77.html
 
L

Les Peabody

That worked great, I figured there would be a way to access the parent
window. Thanks Steve.

~Les Peabody
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top