# Sharing variabe in multiple javascript files

**URL:** <https://www.ruby-forum.com/t/sharing-variabe-in-multiple-javascript-files/116428>\
**Category:** Rails\
**Created:** [October 5, 2007, 12:02pm UTC](https://www.ruby-forum.com/t/sharing-variabe-in-multiple-javascript-files/116428 "2007-10-05T12:02:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kirankinuforu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/977dab/32.png) [@kirankinuforu](https://www.ruby-forum.com/u/kirankinuforu)\
**Post date:** [October 5, 2007, 12:02pm UTC](https://www.ruby-forum.com/t/sharing-variabe-in-multiple-javascript-files/116428/1 "2007-10-05T12:02:43Z")

</div>

Hi friends,

I have created a flag variable and some functions to retrive and update  
its vales.  
1)getFlag():  
returns the value of the flag  
2)toggleFlag():  
toggle value of flag.  
I have used one .js file to contain functions and  
one .rhtml file which uses those functions.  
I have used those functions to avoid multiple  
popup windows the window is able to open only when the flag is true.  
Initially flag is true when window is opened it is set to false and when  
window is closed the flag become true to allow other window to be open.  
But in this flow when i add some alert boxes to see the  
values it shows correct values till one window is got closed but after  
it shows flag as false.

please help me…

Kiran  
removed\_email\_address@domain.invalid
