/    Sign up×
Community /Pin to ProfileBookmark

Hi,

Can anyone help me with a javascipt code for progress bar.
I need to start and the stop progress bar
when ever the request starts and ends.
I am using JSP as my presentation layer

Regards
Sanjeev

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@TheBearMayMay 18.2005 — Here's a real simple one:
<i>
</i> &lt;table style="border:2px outset red;"&gt;
&lt;tr style="height:5px;font-size:5px;padding:0px;margin:0px;"&gt;
&lt;td id="td0" style="width:5px"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td id="td1" style="width:5px"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td id="td2" style="width:5px"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td id="td3" style="width:5px"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td id="td4" style="width:5px"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td id="td5" style="width:5px"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td id="td6" style="width:5px"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td id="td7" style="width:5px"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td id="td8" style="width:5px"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td id="td9" style="width:5px"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;script&gt;
var progInx = -1;
function fillBar(){
progInx++;
if (progInx == 10){
progInx=0;
for (i=0;i&lt;10;i++){
document.getElementById("td"+i).style.backgroundColor="#FFFFFF";
}
}
document.getElementById("td"+progInx).style.backgroundColor="blue";
setTimeout("fillBar()",5000);
}
fillBar();

<i> </i>&lt;/script&gt;
Copy linkTweet thisAlerts:
@VladdyMay 18.2005 — You call this simple :rolleyes:

I got to give the "Most Inventive Misuse of Tables" award.

One block element is all you need:

HTML:
&lt;div id="pbar"&gt;&lt;/div&gt;

CSS:
&lt;style type="text/css"&gt;
#pbar
{ position: absolute; /* relative will do too
- goal to make it offset parent */
width: 400px;
height: 50px;
border: solid #000 1px;
padding: 0;
margin: 0;
}

#pbar div
{ padding: 0;
margin: 0;
width: 50%;
height: 100%;
background: #00f;
} <br/>
&lt;/style&gt;


Javascript:
&lt;script type="text/javascript"&gt;

function pbar(element)
{ this.el = element;

<i> </i>this.start = function(numSteps,period) //Period in seconds,
<i> </i> { this.bar = this.el.appendChild(document.createElement('div'));
<i> </i> this.bar.style.width = '0';
<i> </i> this.advance = 100/numSteps;
<i> </i> this.currStep = 0;
<i> </i> this.timer = setInterval('pbar.instances['+this.id+'].step()',period*1000);
<i> </i> };
<i> </i>this.step = function()
<i> </i> { var barWidth = this.advance*(++this.currStep);
<i> </i> barWidth = barWidth&gt;100?100:barWidth;
<i> </i> this.bar.style.width = barWidth+'%';
<i> </i> if(barWidth==100) clearInterval(this.timer);
<i> </i> window.status +='.';
<i> </i> }
<i> </i>this.reset = function()
<i> </i> { this.el.removeChild(this.bar);
<i> </i> this.bar = null;
<i> </i> }
<i> </i>this.id = pbar.instances.length;
<i> </i>pbar.instances.push(this);
}

pbar.instances = new Array();

&lt;/script&gt;


Start progress bar:
(new pbar(document.getElementById('pbar'))).start(100,0.1);
Copy linkTweet thisAlerts:
@TheBearMayMay 18.2005 — You call this simple :rolleyes:

I got to give the "Most Inventive Misuse of Tables" award....[/QUOTE]


Knew that would draw someone's ire. ?
Copy linkTweet thisAlerts:
@felgallMay 18.2005 — Looks like a good way to take a slow loading web page and make it even slower.
×

Success!

Help @sanjeevkoppal spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...