Hello all, I want to keep a variable global, and access its content outside the .submit handler function below: $(document).ready(function() { name="1"; pass = "2"; /*helper function that changes name and pass values: name = the value contained in the name input text field of the form pass = the value contained in the pass input text field of the form*/ $("#loginForm").submit(function() { /*changes values correctly*/ } alert(name); Alert gives me value "1" instead of the value attributed in the function. How can I transfer the value inside the function to an outside variable? Thanks in advance, Iulia
If a variable is set in the global scope ie: [script] <script> var a = 'a'; function test() { alert(a); } test(); </script> [/script] As you can see "a" is accessible to the test() function even thou we haven't passed it to it. Can you post some of your code?