Storing a parameter and passing it to another page

bigcougar

New Member
How can a person store a value after a JavaScript has been executed, to pass it on to another function?

I tried defining global variables outside the functions. I then assign them the desired value within a function. However, when I run the second function the value of the global variable is read from its initialization line. :confused:
 

onlinetraining

New Member
Does the first function really modified that global variable?
I would use the alert(..) to see what new value that global variable has been given before exiting the first function.
Also make sure the second function does not use a parameter or local variable of the same name as that global variable.
 

smoovo

New Member
In Javascript you should define the variables outside the function to make them "global", but inside the function don't use again the "var" assignment.

Example
HTML:
var a = 1;

function GetSum() {
a++;
alert(a)
}

GetSum();

To learn more about variables, Google "javascript variable scope".

- Enjoy.
 
Top