Jump to content

Javascript Progress Bar

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
dirkfirst

dirkfirst

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 354 posts
I've got some PHP that does a lot of database instructions. I'd like to display a progress bar on the webpage as this php script is cycling and update it on each row.

Is there a tutorial out there for this? How hard is this to do?

#2
Void

Void

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 411 posts
A javascript progress bar is not hard to do. So you want to display a "loading" progress bar like in flash, correct?
Void

#3
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Well im not sure coz im just a beginner in JavaScript but maybe this will help you:-

http://wsabstract.co...ogressbar.shtml

I just dont know, is this what you mean?

or here is another example:-

http://www.webconcer...progressbar.asp

but this is an example to use with ASP pages!

#4
dirkfirst

dirkfirst

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 354 posts
The first one is what I need but how does the progress update? I'd like to run some PHP and as the php updates the progress bar updates. Any idea how to do this Tcm?

#5
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Umm I dont know alot JavaScript, but I'm seeing that in the script there is:-
var duration=3 // Specify duration of progress bar in seconds
So I dont think that you can update this bar as the Script loads! you need to specify a specific time!
Well perhaps if you are good at PHP you could modify it!

EDIT:-
Or you could try this:-



<html>

<script>

var secondWindow = false;

function ProgressBar(sLength) {


var BarLength = 400;

var iLength = parseFloat(sLength);

var Bar = parseInt(iLength); 

if(Bar==0)Bar=1;

var Trough = (BarLength - Bar);

if(Trough==0){Trough=1;Bar=99;}


if(Bar >99) {Bar=99; Trough=1;}

if(Trough <0) {Trough=1;Bar=99;}


var leftVal = (screen.width-490) / 2;

var topVal = (screen.height-20) / 2;

var cellLayer="id1";



if(secondWindow == false) { 


if (navigator.appName=="Microsoft Internet Explorer"){


var theWindow = 


'width=490,height=20,left='+leftVal+',top='+topVal  +',menubar=no,toolbar=no,location=no,personalbar=n  o,status=no,scrollbars=no,directories=no,resizable  =no';

Window02 = window.open('','wind',theWindow);

Window02.document.open();

Window02.document.write('<html><head><script>window.onunload=function(){window.close();} <\/script><title>RezTrip Administrator Application - Please Wait.....Page is loading.</title></head><body bgColor=#EAF2FF><div id=t1 style="position:absolute; top:10; left:10; background-color:#000000; z-index:2; height:20px;"></DIV><div id=t2 style="position:absolute; top:10; left:10; background-color:#cccccc; z-index:1; height:20px; border:#ff0000 1px solid;"></div></body></html>');


Window02.document.close();

}

secondWindow = true;

}

if (secondWindow == true){

if (navigator.appName=="Microsoft Internet Explorer"){


if(!Window02.closed){

if(Bar <0 || Trough<0) alert("hello");

Window02.document.getElementById("t1").style.width=(Bar * (BarLength/100)).toString();

Window02.document.getElementById("t2").style.width=BarLength;


}


}


secondWindow = true;

}


} 

function demo(){

progressCounter=0;

progressCount=parseFloat(100/250);

for(i=0;i<250;i++){

progressCounter+=progressCount;

ProgressBar(progressCounter);

}

if (navigator.appName=="Microsoft Internet Explorer")

{

if(!Window02.closed)

Window02.close(); 

}

secondWindow = false;

}

</script>

<body>

<input type=button value="show Progress Bar" onClick=demo()>  

</body>

</html>

 

I DID not do this!