Is it possible to declare a global variable inside a javascript function?
If you create any variable inside a function, its scope will be local to that function only and not global. Declare your variable outside the function.