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 1</title>
<SCRIPT language=JavaScript src="test.js"></SCRIPT>
</head>
<body>
<p align="center"><b><font size="6">Page 1</font></b></p>
<p align="center"> </p>
<p align="center"> </p>
<form name="form1">
<div align="center">
<center>
<table border="1" width="764" height="97">
<tr>
<td width="373" height="97"><b><u><font size="5">textbox1 - input</font></u></b></td>
<td width="375" height="97"><input type="text" name="input" size="20"></td>
</tr>
</table>
</center>
</div>
<p align="center"><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 = "file://c:\\My Documents\\My Webs\\page2.htm";
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="test.js"></SCRIPT>
</head>
<body>
<p align="center"><b><font size="6">Page 2</font></b></p>
<p align="center"> </p>
<p align="center"> </p>
<form name="form2">
<div align="center">
<center>
<table border="1" width="783" height="126">
<tr>
<td width="373" height="126">
<p align="center"><b><font size="5">output from textbox1 page1</font></b></p>
<p align="center"><input type="hidden"name="output" size="20" ></td>
<td width="394" height="126"><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="hidden"name="output" size="20" value = "5"></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.
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 1</title>
<SCRIPT language=JavaScript src="test.js"></SCRIPT>
</head>
<body>
<p align="center"><b><font size="6">Page 1</font></b></p>
<p align="center"> </p>
<p align="center"> </p>
<form name="form1">
<div align="center">
<center>
<table border="1" width="764" height="97">
<tr>
<td width="373" height="97"><b><u><font size="5">textbox1 - input</font></u></b></td>
<td width="375" height="97"><input type="text" name="input" size="20"></td>
</tr>
</table>
</center>
</div>
<p align="center"><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 = "file://c:\\My Documents\\My Webs\\page2.htm";
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="test.js"></SCRIPT>
</head>
<body>
<p align="center"><b><font size="6">Page 2</font></b></p>
<p align="center"> </p>
<p align="center"> </p>
<form name="form2">
<div align="center">
<center>
<table border="1" width="783" height="126">
<tr>
<td width="373" height="126">
<p align="center"><b><font size="5">output from textbox1 page1</font></b></p>
<p align="center"><input type="hidden"name="output" size="20" ></td>
<td width="394" height="126"><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="hidden"name="output" size="20" value = "5"></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.