desjardins2010 Posted December 22, 2010 Share Posted December 22, 2010 Guys/Gals; This below block outputs a very simple progress bar, i'm curious if anyone would see a solution to perform a task when this bar reaches the end as you can see it's set to countinue until width<400 when that 400 is true I and in essence the process is done (even though nothing in reality) i want to display countinue but only when it's done echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' bgcolor='#666666'><tr><td width='506' height='52' valign='top'><script type='text/javascript'>function progress(){if(document.images['bar'].width<400){document.images['bar'].width+=5;document.images['bar'].height=5; }else{clearInterval(ID);}}var ID;window.onload=function(){ID=setInterval('progress();',$cpuspeed);}</script><img src='images/white.gif' name='bar'/><br /><font color='#ffffff'>Cracking....</font></td></tr></table>"; any dideas Quote Link to comment Share on other sites More sharing options...
micah1701 Posted December 22, 2010 Share Posted December 22, 2010 the problem is an issue of server-side vs client-side scripts. the variable $cpuspeed that you're outputting is sent from the server side to the user's browser where javascript (a client-side script) uses it in its function. Once the the serverside has sent its variable to the browser, thats the end of it. Unless you're doing some tricky AJAX stuff where the browsers constantly talkes to the server, what you're trying to implement just won't work. Quote Link to comment Share on other sites More sharing options...
lastkarrde Posted December 22, 2010 Share Posted December 22, 2010 There is a progress bar extension in PECL which you could find useful. It requires PHP 5.2, but allows you to easily "check" with the server how much of the file has been uploaded with uploadprogress_get_info function. Quote Link to comment Share on other sites More sharing options...
desjardins2010 Posted December 22, 2010 Author Share Posted December 22, 2010 thanks guys for your input, heres the thing the progress bar is completly fake it's not calculating anything, simply in a game I'm making I want the progress bar when finished to forward to another page acting as if it just did something... the $cpuspeed varible you see is why I like this little progression bar cause I can have it move faster for users with higher cpuspeed.. just can't get a redirect when this progress bar is full? Quote Link to comment Share on other sites More sharing options...
lastkarrde Posted December 23, 2010 Share Posted December 23, 2010 (Javascript) when the progress bar reaches 100% you can window.location = 'http://www.example.com'; [code] and it will redirect. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.