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
Site that have nice but raising number of visits / hits, heavily operates on
My site needs to be able to serve data in different languages. I set
My site has a drop-down menu built in CSS and JavaScript that drops down
My site is a music site that with 24 single song players on each
SITE ADMIN: WOULD YOU PLEASE REMOVE THIS POST? For example, I have tt =
Test site: http://wfwgm.stage.philosophydesign.com/ I have included: <script src=http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js></script> to give :before support in IE6
Site: http://clientfiles.priworks.com/lgmanagedportfolios/test/investment.html I have been working at this web page for a while now
My site has a messaging feature where one user may message another. The messages
http://site.com/Admin/User/Index Admin - area. I need: get controller Account (path /site.com/AccountController) @Html.ActionLink(Log On, LogOn,

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.