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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

seems simple yet...

Status
Not open for further replies.

balaban32

Technical User
May 7, 2002
3
US
Here is what I am trying to do but I can't get to work.
I obtain a value for the variable 'one' through an inputbox from page1 form1 table1. I then use an external .JS file to do a calculation with the variable 'one'. I would like then to be able open a new page 'page2.htm' in the same window as page1.htm used to be and to display the new value of the variable 'one' in a cell in page2 form2 table2. Here is my code which I cannot get to work:


here is the html code for 'page1.htm'

<html>

<head>
<title>Page&nbsp; 1</title>
<SCRIPT language=JavaScript src=&quot;test.js&quot;></SCRIPT>
</head>

<body>

<p align=&quot;center&quot;><b><font size=&quot;6&quot;>Page&nbsp; 1</font></b></p>
<p align=&quot;center&quot;>&nbsp;</p>
<p align=&quot;center&quot;>&nbsp;</p>

<form name=&quot;form1&quot;>
<div align=&quot;center&quot;>
<center>
<table border=&quot;1&quot; width=&quot;764&quot; height=&quot;97&quot;>
<tr>
<td width=&quot;373&quot; height=&quot;97&quot;><b><u><font size=&quot;5&quot;>textbox1 - input</font></u></b></td>
<td width=&quot;375&quot; height=&quot;97&quot;><input type=&quot;text&quot; name=&quot;input&quot; size=&quot;20&quot;></td>
</tr>
</table>
</center>
</div>
<p align=&quot;center&quot;><INPUT onclick=run() type=button value=go name=go></p>

</form>

</body>

</html>


here is the .JS file 'test.js'


var one = 0;

function run()
{
one = form1.input.value;
one = one + 1;

//which statement would I need to use to be able to open page2.htm in the same window
//as page1.htm was open in. I tried both of the following but I am missing something.

//location.href = &quot;file://c:\\My Documents\\My Webs\\page2.htm&quot;;
win = window.open('file://c:\\My Documents\\My Webs\\page2.htm');
doc = win.document; //opens up the document for output
doc.form2.output.value = one; //outputs the value to the table in page2.htm


}


here is the html for page2.htm

<html>

<head>
<title>Page 2</title>
<SCRIPT language=JavaScript src=&quot;test.js&quot;></SCRIPT>

</head>

<body>

<p align=&quot;center&quot;><b><font size=&quot;6&quot;>Page 2</font></b></p>
<p align=&quot;center&quot;>&nbsp;</p>
<p align=&quot;center&quot;>&nbsp;</p>
<form name=&quot;form2&quot;>
<div align=&quot;center&quot;>
<center>
<table border=&quot;1&quot; width=&quot;783&quot; height=&quot;126&quot;>
<tr>
<td width=&quot;373&quot; height=&quot;126&quot;>
<p align=&quot;center&quot;><b><font size=&quot;5&quot;>output from textbox1 page1</font></b></p>
<p align=&quot;center&quot;><input type=&quot;hidden&quot;name=&quot;output&quot; size=&quot;20&quot; ></td>
<td width=&quot;394&quot; height=&quot;126&quot;><script>document.write(window.document.form2.output.value);</script></td>
</tr>
</table>
</center>
</div>
</form>
</body>

</html>


Here is the problem. After I pass the value of the variable to the hidden textbox 'output' I want to be able to write that value in the adjacent cell without using a textbox thats why I have the 'document.write' script in the table cell. This is where I run into trouble, if assign a value to the hidden 'output' box in the html something like <td>...<input type=&quot;hidden&quot;name=&quot;output&quot; size=&quot;20&quot; value = &quot;5&quot;></td> then the 'document.write' script in the adjacent cell works fine and the value of 'output' displays in the adjacent cell, but if instead do not assign it a value through the html but I pass it through the external test.js file the 'output' textbox gets the value but the adjacent cell will not display it. Does anyone know how to resolve this problem. One more thing my reason for doing things this way is because I would like to use the the html table to format my output without having to put it in textboxes. Any help advice and sugestions is much appreciated. Thank you.
 
u cant do it that way
liking both page with the script dosent means he keeps the value
its a diferent execution on each page
use cookies read this thread216-266938
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
Your best bet is to put the value into a cookie on page1, then read from the cookie to put in page2. You could pass the value in the URL, but if someone left the page and then went back to it, the information would be gone. The way it looks like you're trying to do this, you'd need to use ASP or other server side scripting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top