Jump to content

[SOLVED] adding integer


csckid

Recommended Posts

function trans(){

setInterval("animate()",100);

}
i=0.0;
x=0;
function animate(){
i=i+.1;
if((.1+i)>1) return;
x=parseInt(x)+10;

alert(x);


a=document.getElementById('menu');
a.style.opacity=0.1+i;//a.filters.alpha.opacity=10+parseInt(x);
}

in alert box value of x shown is NaN, it is not adding integer

plz help

Link to comment
https://forums.phpfreaks.com/topic/152225-solved-adding-integer/
Share on other sites

The only thing I can think of is that trans() is being called before i and x are being set. Try moving:

 

i=0.0;
x=0;

 

... to the very top of your script, or adding it to the 'window.onload' event (Though you'd still need to declare them as globals).

 

Adam

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.