Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-16-2004, 06:26 AM   PM User | #1
lilmeanman
New to the CF scene

 
Join Date: Jul 2004
Location: WY
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
lilmeanman is an unknown quantity at this point
Arrow OK i have a simple question

Ok i have a simple JavaScript question:

I want to create a variable on page 1 (page1.html)
Which has a value of 66

On the second page, i want it to keep that variable, and print it's value.

How can i make that variable "stay" in memory?
lilmeanman is offline   Reply With Quote
Old 07-16-2004, 06:36 AM   PM User | #2
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
http://www.webxpertz.net/forums/faq....aq_wxfaq_1_1_2
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 07-16-2004, 06:36 AM   PM User | #3
peterinwa
Regular Coder

 
Join Date: Jun 2002
Location: Vancouver, WA
Posts: 233
Thanks: 2
Thanked 0 Times in 0 Posts
peterinwa is an unknown quantity at this point
I'm such an ignorant self-taught life-time-novice that this is the blind leading the blind, but I'll take a stab at it.

To the best of my knowledge when you load a new page you lose everything in memory. There are two workarounds that I know of:

1. Save the variable from page one in a cookie which is loaded by page two.
2. Don't actually change the "page" but give that illusion by rewritting it using frames. See my recent posts on the subject.

peterinwa

P.S.

Edit to the above... glenngv and I posted almost exactly the same time. Looking at his ref I didn't do so bad!

Last edited by peterinwa; 07-16-2004 at 06:39 AM..
peterinwa is offline   Reply With Quote
Old 07-16-2004, 01:10 PM   PM User | #4
Willy Duitt
Banned

 
Join Date: Sep 2003
Posts: 3,620
Thanks: 0
Thanked 0 Times in 0 Posts
Willy Duitt is an unknown quantity at this point
Or for sessions you can pass your variable on the window.name property....

Page One:
<script>
window.name = 66; // or your variable //;
</script>

Page Two:
<script>
document.write(window.name);
</script>

.....Willy
Willy Duitt is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:37 PM.


Advertisement
Log in to turn off these ads.