PDA

View Full Version : making a imported variable ( from php ) into a number



VoS
November 2nd, 2004, 02:29 PM
hey ;)

Quick question...
im importing a few variables with this


myVars = new LoadVars();
myVars.load("getinfo.php?user1="+userN+"&pass45="+passN+"&random="+refresh1,"0");
myVars.onLoad = function() {
_root.cash=myVars.balance;
....

thats all working good ..
but now how do i make a variable say...
_root.cash
into a a number which can be used in equations or used for logical compariosons such as < > ==
thank you

samotboy
November 2nd, 2004, 11:10 PM
so its kinda coming back up as a string and wheny ou use in a equation it sas NaN the problem is you probaly need parseFloat which convert a string in a number so.
cashnumber =parseFloat(_root.cash)

JUD
November 3rd, 2004, 02:54 AM
You could try this.
myVars = new LoadVars();
myVars.load("getinfo.php?user1="+userN+"&pass45="+passN+"&random="+refresh1,"0");
myVars.onLoad = function() {
_root.cash=Number(myVars.balance);
....