sharing variables between javascript functions

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
toraj58
Forum Newbie
Posts: 12
Joined: Sun Jun 15, 2008 12:40 am

sharing variables between javascript functions

Post 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?
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: sharing variables between javascript functions

Post by kaszu »

Define variable outside the functions:

Code: Select all

var my_variable = 'abc';
function a() { my_variable = 3; }
function b() { alert(my_variable); }
toraj58
Forum Newbie
Posts: 12
Joined: Sun Jun 15, 2008 12:40 am

Re: sharing variables between javascript functions

Post by toraj58 »

thanks for your reply...but my problem was another thing but i discribed it improperly...anyway i found solution for my problem.
Post Reply