troubleshooting Question

Javascript asp.net progress bar

Avatar of dba_damion
dba_damionFlag for Afghanistan asked on
JavaScriptASP.NETAJAX
2 Comments1 Solution619 ViewsLast Modified:
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
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros