Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LoadVars() and global variable problems

Status
Not open for further replies.

clemrock

Programmer
May 20, 2004
118
US
Hello,

I have an ongoing problem w/ the LoadVars() function and the scope of variables. I would loke to have a situation where I can read the values of a file, set those read values to global variables and use them throughout the program. Now know I can set a text box to recieve the read values but It seems like a copout

Here's the code I'm using:

_global.db_script_data = new LoadVars();
db_script_data.onLoad = function(success)
{
if( success == true )
{
_global.user_level = db_script_data.user_level;
_global.user_id = db_script_data.user_id;
}
else
{
txt_output += "\n !!!!No read vars failed!";
}
trace( "user_id: " + user_id ); //will show user_id as "1"
}
db_script_data.sendAndLoad( "verify.php", db_script_data, "POST");

trace( "user_id: " + user_id ); //will show user_id as undefined

I know there's probably an easy solution staring me in the face.

Thanks,
Clem
 
db_script_data = new LoadVars();
db_script_data.onLoad = function(success) {
if (success) {
_global.user_level = db_script_data.user_level;
_global.user_id = db_script_data.user_id;
} else {
txt_output += "\n !!!!No read vars failed!";
}
};
db_script_data.sendAndLoad("verify.php", db_script_data);

the above looks more correct...try and see
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top