barkster Posted April 16, 2008 Share Posted April 16, 2008 Why doesn't this work var f = document.form1; function1 () { alert(f.tb1.value); } fuction2 () { alert(f.tb2.value); } but this does? function1 () { f = document.form1; alert(f.tb1.value); } fuction2 () { f = document.form1; alert(f.tb2.value); } Quote Link to comment Share on other sites More sharing options...
ucffool Posted April 17, 2008 Share Posted April 17, 2008 defining a variable inside of a function makes it available within that function. defining a variable outside of a function makes it available within a function ONLY IF you pass that variable to the function (in the parenthesis after the function's name) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.