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 8582447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:17:41+00:00 2026-06-11T21:17:41+00:00

I have created an application in javascript where a user clicks a button to

  • 0

I have created an application in javascript where a user clicks a button to start a timer, presses a series of buttons and then clicks another button to stop the timer. The time each button is clicked is recorded in milliseconds and the values are collected in an array. This is all working fine.

The next part is where I am having trouble. I’d like to display the values of the array in a timeline. I have a script that gets the width of a div that is set to 100% wide. This width is different based on the resolution of the device that the user is using. What I need to do is create a formula that scales the millisecond values stored in my array to the appropriate values based on the width of my div.

For reference:
//Here's my array:
counterbArray = counterbString.split(", ");
counterbArrayL = [counterbArray.length];

//Getting width of div:
var timelinewidth = $("#timeline").width();

//Plotting the points as images:
for (i=1; i<(counterbArrayL); i++)
    {
    document.getElementById('timeline').innerHTML =     document.getElementById('timeline').innerHTML + "<img src='event.gif' width='16' height='15' class='plot' style='left:" + *each value from formula here* + "px' >";         
    }

Thanks!

  • 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-06-11T21:17:42+00:00Added an answer on June 11, 2026 at 9:17 pm

    You also need the variable containing the time when the user clicked stop.

    var timeofstop = *****;
    
    counterbArray = counterbString.split(", ");
    counterbArrayL = [counterbArray.length];
    
    //Getting width of div:
    var timelinewidth = $("#timeline").width();
    
    var currentleft;
    
    //Plotting the points as images:
    for (var i = 0; i < counterbArrayL; i++) {
    
        currentleft = Math.round((counterbArray[i] / timeofstop) * timelinewidth);
    
        document.getElementById('timeline').innerHTML = document.getElementById('timeline').innerHTML + "<img src='event.gif' width='16' height='15' class='plot' style='left:" + currentleft + "px' >";
    }
    

    You might also want to substract 8 from the currentleft if you want to center the image.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an application.in the app i start a countdown timer and save
I have created an application that uses settings.settings to store some user specific settings
i have created an application in jquery and google maps javascript v3 , in
In my application I have updatepanel with few buttons. One of those button is
I have created application where i just need to access data form assets folder.
I have created an application in windows form. Once I submit the application, the
I have created Windows Application. In this, I have multiple tables in dataset, now
I have created an application that connect on a web-server and reads an xml
I have created an application in facebook,all is working fine except the publish to
I have created an application using Adobe Flex. I took all the files from

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.