Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Issues with JS loading bar and other website problems.

Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I have a loading bar I made in JS that loads based on how many hours the user adds to their itinerary.

The current version of the loading bar can be viewed here: 50 things port henry

The particular problem I'm having is when it comes to rounding the loading bar width after the calculation.

The current code takes the hourly value associated with each button and creates a percentage that dictates the loading bar's length. However there is a rounding error associated with the calculation that causes the loading bar to not always match the length exactly.

Here are the most important snippets of code:

This section of code is responsible for getting the hourly value from the "add to itinerary" button.

The set duration function which sets the loading bar's length.

I tried performing this calculation without any rounding and got loading bar errors. I've tried rounding the result to the nearest integer and the nearest multiple of 5. I still get issues, particularly when the loading bar is being shortened, which is the exact same calculation just inverted.

Some other issues:

1. On the live website, the hover effect and clickability don't register on all of the buttons. I've tried inspect element and can't see any different between the buttons that work and dont.

2. If I press one itinerary button quickly, I'm able to bypass the maximum allowable hours. For example, if the max itinerary is 10 hours, if I click the button very quickly I can have activities totalling over ten hours. I don't understand why the pace of the clicks matters when it should be going through the if else loop every time.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic