how can i use a variable in one frame in another frame?

G

Guest

I wish to use the data in a variable created in one frame, and use it in
another frame.

how do i get that data?

thank you in advance.
 
S

Steve Easton

This answers one of your other posts also.
You need to give the element where you want to write the value to an id and then write to the id.

document.write("itemname");

won't do it

lets say your iframe is named container ( see answer to your earlier post )
and you want to write itemname to a place inside of container, for example a cell in a table.

<td id = "nameofitem">


document.all.container.nameofitem.innerHTML = "itemname" ;


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
G

Guest

this should give you an idea what i am trying to do.

thank you.



<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>page3</title>
</head>

<!--Main Frameset-->
<frameset frameborder="no" cols="174,*" >
<frame name="page1" src="new_page_1.htm" scrolling="auto">
<frame name="page2" src="new_page_2.htm" target="_blank"
scrolling="auto">
</frameset>
</frameset>

<noframes>
<body>
</body>
</noframes>
</html>








<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Page 2</title>
<base target="_blank">
</head>

<body>

lets say that these variable have been set to these values via a pull down
menu in this frame
<script language="javascript">
_numberofitems=1
_costofitem=1
</script>


</body>

</html>









<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>page1</title>
</head>

<body>

<p align="center">Your order</p>
<p align="center">&nbsp;</p>

<td id = _numberofitems></td>
<td id = _costofitem></td>
£
<td id = adddecumal(_numberofitems*_costofitem)></td>
p


</body>
</html>
 
S

Steve Easton

In line
Please don't take anything I say as a "put down" because it is not meant to be that way

this should give you an idea what i am trying to do.

thank you.



<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>page3</title>
</head>

<!--Main Frameset-->
<frameset frameborder="no" cols="174,*" >
<frame name="page1" src="new_page_1.htm" scrolling="auto">
<frame name="page2" src="new_page_2.htm" target="_blank"
scrolling="auto">
</frameset>
</frameset>

All of your "global" variables that are goin to be used in page1 and page 2 need to be named here.
either by physically declaring them, or placing them in a .js file and calling it.

<noframes>
<body>
</body>
</noframes>
</html>








<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Page 2</title>
<base target="_blank">
</head>

<body>

lets say that these variable have been set to these values via a pull down
menu in this frame
<script language="javascript">
_numberofitems=1
_costofitem=1
</script>


1. These variable names **must** be global and established as such when the main page loads
2. Variable names **must** begin with a letter and "should" only contain letters and numbers.

abc1 is oj
d1ef is ok
rumplestiltskin is ok

_abc is not ok

</body>

</html>

<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>page1</title>
</head>

<body>

<p align="center">Your order</p>
<p align="center">&nbsp;</p>

<td id = _numberofitems></td>
<td id = _costofitem></td>

id names must be letters and numbers just like variables.
£
<td id = adddecumal(_numberofitems*_costofitem)></td>
p

You can't perform a mathimatical function simply by placing it in an id tag.
You must have javascript perform the math as part of creating a new variable, and then write the
variable to the id using

document.all.adddecumal.InnterHtml = "newvariablename";


That said, it appears you're trying to jump into the deep end of the javascript pool without
sticking your toe in the water first.

Go here: http://www.gatescript.com/default.asp and start reading and playing with the example
scripts.
It is an excellent learning tool.

hth


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
G

Guest

now i am more confused!!!

i have looked at those sites and still can not understand how this works.
once i see it i will see how it works.

i have below the test pages i have been using to get this to work.

please could you be kind enough to change where i am going wrong and let me
know the correct way to get what i need.

i have only been working with global variables for a few days!

thank you again.


file1
---------------

<html>

<head>
<title>page 1</title>
</head>

<!--Main Frameset-->
<frameset frameborder="no" cols="174,2*" >
<frame name="page3" src="page3.htm" scrolling="yes">
<frame name="page2" src="page2.htm" target="_blank" scrolling="auto">
</frameset>
</frameset>

<noframes>
<body>
</body>
</noframes>
</html>

-----------------

file2
------------
<html>

<head>
<title>Page 2</title>
<base target="_blank">
</head>

<body>

lets say that these variable have been set to these values via a pull down
menu in this frame. see script in code.
<script language="javascript">
numberofitems=1
costofitem=1
</script>


</body>

</html>

----------------

file3
--------------
<html>

<head>
<title>page 3</title>
</head>

<body>

i would like to see the variables printed in this window that were setup
from another frame.


</body>
</html>
 

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