gli Posted June 23, 2008 Share Posted June 23, 2008 Hi! I'm begginer to JavaScript. Heres my code var opacity = 0; function fadeout() { if(opacity <= 1) { opacity = opacity + 0.1; document.getElementById('imgMid').style.opacity=opacity; window.setTimeout('fadeout()', 60); } } It's working but only once, because i have slideshow, and on next picture, the opacity variable is 1, and i tried many ways but i can't get it work for all slideshow. Please can you give me way in what i can do that. Yes i tried 'for loops' and 'while' but nothing hapenned. Thanks Link to comment https://forums.phpfreaks.com/topic/111574-solved-boolien-alternative/ Share on other sites More sharing options...
lemmin Posted June 23, 2008 Share Posted June 23, 2008 It would make sense to make a loop instead of recursively calling the function so that you can set the opacity variable each time the function is called. If you don't want to do that, I think it would work to just set the opacity back to 0 and return once the fade is done: var opacity = 0; function fadeout() { if(opacity <= 1) { opacity = opacity + 0.1; document.getElementById('imgMid').style.opacity=opacity; window.setTimeout('fadeout()', 60); } else opacity = 0; } Link to comment https://forums.phpfreaks.com/topic/111574-solved-boolien-alternative/#findComment-572727 Share on other sites More sharing options...
gli Posted June 25, 2008 Author Share Posted June 25, 2008 thanks Link to comment https://forums.phpfreaks.com/topic/111574-solved-boolien-alternative/#findComment-574215 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.