Page 1 of 1

sharing variables between javascript functions

Posted: Sat Jun 28, 2008 6:58 am
by toraj58
i have two javascript fuctions in my page and i want to have access to some variables of the first function within second function. how shoud i do that?

Re: sharing variables between javascript functions

Posted: Sat Jun 28, 2008 8:51 am
by kaszu
Define variable outside the functions:

Code: Select all

var my_variable = 'abc';
function a() { my_variable = 3; }
function b() { alert(my_variable); }

Re: sharing variables between javascript functions

Posted: Sun Jun 29, 2008 5:46 am
by toraj58
thanks for your reply...but my problem was another thing but i discribed it improperly...anyway i found solution for my problem.