Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing A Variable To Another Web Page

Status
Not open for further replies.

FontanaS

Programmer
May 1, 2001
357
US
Hi! I have the following code that will reload the parent web page and close the child web page -

<script type="text/Javascript">
opener.location.reload();
window.close("</script>

This code is in the child web page and works fine. The problem is that BEFORE I reload the parent web page, I want to pass a variable to it and store in a variable.

Is it as simple as -

<script type="text/Javascript">
opener.location.OrderFile1 = lvvar
opener.location.reload();
window.close("</script>

OrderFile1 is the text box on the parent web page
lvvar is the variable on the child web page i need passed to the parent web page
 
opener.getElementById('OrderFile1').value = lvvar;

As long as the id of the textbox id= 'OrderFile1'

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
when you reload the page, the data stored in the variable will be lost. you might want to consider reloading the page in this manner:

Code:
opener.location = opener.location.href + "?lvvar=" + lvvar;

and then parse the value out of the query string on page load.



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Hi,

I keep getting an "object does not support this method or property.

Here is the code in the parent -
<td align="center"><input id="OrderFile1" type="text" size="30" maxlength="250" name="OrderFile"></td>

Here is the code in the child -
<!--FUNCTION TO SAVE AND UPLOAD THE FILES CHOSEN-->
<%FUNCTION SaveFiles
Dim Upload, fileName, fileSize, ks, i, fileKey, lvvar

Set Upload = New UploadFilesCode
Upload.Save(uploadsDirVar)

'IF SOMETHING FAILS INSIDE THE SCRIPT, BUT THE EXCPETION IS HANDLED
If Err.Number<>0 then Exit function

SaveFiles = ""
ks = Upload.UploadedFiles.keys
IF (UBound(ks) <> -1) THEN
SaveFiles = "<B>Files uploaded:</B> "
FOR EACH fileKey IN Upload.UploadedFiles.keys
SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) "
lvvar = Upload.UploadedFiles(fileKey).FileName
NEXT
ELSE
SaveFiles = "The File Name Specified Does Not Correspond To A Valid File In The System. Please Select A Valid File."
END IF%>

<!--ASSIGN UPLOAD VALUE TO THE PARENT FORM-->
<script type="text/Javascript">
window.opener.getElementById('OrderFile1').value = lvvar;
</script>
<%END FUNCTION%>
 
I have been playing around and got it work mostly.

<!--FUNCTION TO SAVE AND UPLOAD THE FILES CHOSEN-->
<%FUNCTION SaveFiles
Dim Upload, fileName, fileSize, ks, i, fileKey, lvvar

Set Upload = New UploadFilesCode
Upload.Save(uploadsDirVar)

'IF SOMETHING FAILS INSIDE THE SCRIPT, BUT THE EXCPETION IS HANDLED
If Err.Number<>0 then Exit function

SaveFiles = ""
ks = Upload.UploadedFiles.keys
IF (UBound(ks) <> -1) THEN
SaveFiles = "<B>Files uploaded:</B> "
FOR EACH fileKey IN Upload.UploadedFiles.keys
SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) "
lvvar = Upload.UploadedFiles(fileKey).FileName%>
<!--ASSIGN UPLOAD VALUE TO THE PARENT FORM-->
<script type="text/Javascript">
window.opener.document.getElementById('OrderFile1').value = 'lvvar';
</script>
<%NEXT
ELSE
SaveFiles = "The File Name Specified Does Not Correspond To A Valid File In The System. Please Select A Valid File."
END IF%>
<%END FUNCTION%>

On the parent web page it puts lvvar into the text box and not the value of lvvar. I believe i need to pass the value of lvvar to the javascript code - is that correct? If so, how do I do that?

THANKS!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top