to pass a value from one function to another,
pass the value as a parameter of the function call.
as follows:
---------------------------------------------------
function smile () // function header
{
var me; // variable declaration
sad (me); // function call ( with parameter )
return; // return program control to calling function
}
function sad (me) // function header
{
alert (me); // output value to the terminal
return; // return program control to calling function
}
----------------------------------------------------
if you simply need to access a variable from inside of multiple functions,
declare the variable outside of all functions, thus making it a global variable.
then you will be able to access it from with any subsequent funcitons
as follows:
-----------------------------------------------------
var me;
I think there is a simple answer to your question.
If you have defined a variable, you can use it in as many functions as you want. Its value stays at what ever it was last. You will note that you generally define a variable outside of the function in the first place, then use it in a function. There is no association between a function and a variable per se. So feel free to use a variable in more than one function.
<script . . . .
var whatever
function number1()
...
function number2()
...
</script>
Bookmarks