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); } Link to comment https://forums.phpfreaks.com/topic/101367-form-name-variable/ 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) Link to comment https://forums.phpfreaks.com/topic/101367-form-name-variable/#findComment-519979 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.