dba_damion
asked on
Javascript asp.net progress bar
I have a progress bar but it goes pass complete at 100 percent I want it to stop at 95 percent
function progressBar(idOfContainer, idOfProgress, idOfText, speed) {
// Assign our ids to local variables
var a = _div(idOfContainer);
var b = _div(idOfProgress);
var c = _div(idOfText);
var d = speed;
// Get the widths of the mian container and the progress container
//var widthOfContainer = a.scrollWidth;
//var widthOfProgress = b.scrollWidth;
var widthOfContainer = 517;
var widthOfProgress = 10;
// Calculate the increment based on width of container so it'll be dynamic
var incrementWidth = parseInt(widthOfContainer / 100);
// Progress width
var progressWidth = parseInt(widthOfProgress + incrementWidth);
// Initialize a timer
var timeOfProgress = null;
// Start to increase the width of the progress container to simulate a progress bar
timeOfProgress = setInterval(
function() {
// Increase the width of the progress bar
//b.style.width = progressWidth + "px";
b.style.width = progressWidth + 10;
// Calculate the percentage completed
// good c.innerHTML = Math.ceil((progressWidth / widthOfContainer) * 100) + "% completed";
if Math.ceil((progressWidth / widthOfContainer) * 100) < 95 {
c.innerHTML = Math.ceil((progressWidth / widthOfContainer) * 100) + "% completed";
}
// Stop the timer if the progress bar is the same as the main container
if (progressWidth == widthOfContainer) {
clearInterval(timeOfProgress);
}
// Increase the progress width by adding the increment width
progressWidth = progressWidth + incrementWidth;
}, d);
return false;
}
// Mimic jQuery so we don't have to keep typing document.getElementById()
function _div(id) {
return document.getElementById(id);
}
function AlertStatus() { window.status = 'Please Wait!!!'; }
// Initialize function when page loads
progressBar("div1", "div2", "div3", 100);
function progressBar(idOfContainer, idOfProgress, idOfText, speed) {
// Assign our ids to local variables
var a = _div(idOfContainer);
var b = _div(idOfProgress);
var c = _div(idOfText);
var d = speed;
// Get the widths of the mian container and the progress container
//var widthOfContainer = a.scrollWidth;
//var widthOfProgress = b.scrollWidth;
var widthOfContainer = 517;
var widthOfProgress = 10;
// Calculate the increment based on width of container so it'll be dynamic
var incrementWidth = parseInt(widthOfContainer / 100);
// Progress width
var progressWidth = parseInt(widthOfProgress + incrementWidth);
// Initialize a timer
var timeOfProgress = null;
// Start to increase the width of the progress container to simulate a progress bar
timeOfProgress = setInterval(
function() {
// Increase the width of the progress bar
//b.style.width = progressWidth + "px";
b.style.width = progressWidth + 10;
// Calculate the percentage completed
// good c.innerHTML = Math.ceil((progressWidth / widthOfContainer) * 100) + "% completed";
if Math.ceil((progressWidth / widthOfContainer) * 100) < 95 {
c.innerHTML = Math.ceil((progressWidth / widthOfContainer) * 100) + "% completed";
}
// Stop the timer if the progress bar is the same as the main container
if (progressWidth == widthOfContainer) {
clearInterval(timeOfProgress);
}
// Increase the progress width by adding the increment width
progressWidth = progressWidth + incrementWidth;
}, d);
return false;
}
// Mimic jQuery so we don't have to keep typing document.getElementById()
function _div(id) {
return document.getElementById(id);
}
function AlertStatus() { window.status = 'Please Wait!!!'; }
// Initialize function when page loads
progressBar("div1", "div2", "div3", 100);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER