Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 739373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:23:35+00:00 2026-05-14T08:23:35+00:00

On a site I’m making I need to have a progress bar, I found

  • 0

On a site I’m making I need to have a progress bar, I found one that suited my needs. By default it will incrementally change the color when a certain percentage is reached (0-30 red, 30-70 orange, etc). My only problem is changing them, I can set them easily with a static number such as 50, but when I try to do it dynamically (ie: 2000*.3 = 600) it fails. I don’t know much js/jquery so this is especially difficult for me, if you could help that would be great. I’m pretty sure it’s something really simple I’m missing.

The code that Fails:

var barmax = 2000;
var orangeBound = Math.round(barmax * .3);
var greenBound  = Math.round(barmax * .7);
//alert(orangeBound+":"+greenBound);
$("#pb1").progressBar({ max: barmax, textFormat: 'fraction',
barImage: {
       0: 'images/progressbg_red.gif',
       orangeBound: 'images/progressbg_orange.gif',
       greenBound: 'images/progressbg_green.gif'}
    });

The code that works but I can’t use because it has to be dynamic:

$("#pb1").progressBar({ max: barmax, textFormat: 'fraction',
    barImage: {
       0: 'images/progressbg_red.gif',
       600: 'images/progressbg_orange.gif',
       1400: 'images/progressbg_green.gif'}
    });

If you need to see the source, here. Thanks again!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T08:23:35+00:00Added an answer on May 14, 2026 at 8:23 am

    The problem is that using orangeBound as the key in the object literal means that the string "orangeBound" is used, rather than the value of the variable. Instead, try building the object like so:

    var barImage = {0: 'images/progressbg_red.gif'};
    barImage[orangeBound] = 'images/progressbg_orange.gif';
    barImage[greenBound] = 'images/progressbg_green.gif'
    var barmax = 2000;
    var orangeBound = Math.round(barmax * .3);
    var greenBound  = Math.round(barmax * .7);
    $("#pb1").progressBar({
        max: barmax,
        textFormat: 'fraction',
        barImage: barImage
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
A site that uses username/password for users to log in obviously needs that login
My site has a drop-down menu built in CSS and JavaScript that drops down
A site I am working on that is built using PHP is sometimes showing
Web site: http://www.srstage.d19.us * { padding: 0; margin: 0; } works, but that is
Our site has some very complicated form controls that are submitted and then show
Site 1 has dll's for x amount of object and data calls. Can Site
My site has quite a deep navigation structure and quite often it looks like
A site I'm working on has Flash headers (using swfobject to embed them). Now
What site(s) do you recommend for looking at complimentary colors for site design? It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.