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

  • Home
  • SEARCH
  • 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 7748481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:47:47+00:00 2026-06-01T10:47:47+00:00

I’m trying to make a widget used for controlled time entry that uses up

  • 0

I’m trying to make a “widget” used for controlled time entry that uses up and down arrows to increment each section in addition to allowing you to type the values in by hand. It worked fine(looping over from 12 to 1 and 59 to 1 ect.), but when I added a section that formatted the minutes properly when the value was below 10, it started acting up.

Pressing down acts normally until 10 where it displays, “10” then “09” then “0-1”.

Pressing up after you get to “0-1” goes to “01” but when you get to “08”, it goes back to “01”.

function minFix(mins)
{
if ( mins <= 9)
    {
        mins = "0" + String(mins);
        document.getElementById("mins").value = mins;
    }
else
    {
        document.getElementById("mins").value = mins;
    }
}


function minUp()
{
var mins = parseInt(document.getElementById("mins").value);
if (mins == 59)
    {
        mins = 1;
        minFix(mins);
    }
else
    {
        mins = (mins+1);
        minFix(mins);
    }
}


function minDown()
{
var mins = parseInt(document.getElementById("mins").value);
if (mins == 1)
    {
        mins = 59;
        minFix(mins);
    }
else
    {
        mins = (mins-1);    
        minFix(mins);   
    }

}

The minUp and minDown are called by the up and down arrows respectively and the textbox that displays mins has an ID of mins.

I’m sure I’m missing something simple but I can’t figure it out right now so any help would be much appreciated.

  • 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-01T10:47:48+00:00Added an answer on June 1, 2026 at 10:47 am

    this has to do with your zero that you’re appending. It makes your number into a octal number, so when you read it back in, it’s not being read as a decimal number. Take a look at how parseInt works and you’ll understand. You need to remove the leading zero before parsing.

    Scroll down for the parseInt function here: http://www.javascripter.net/faq/convert2.htm

    so this line var mins = parseInt(document.getElementById("mins").value);

    should be

    var mins = parseInt(document.getElementById("mins").value.replace(/^0+/,""));
    

    Oh, and welcome to Stack! please don’t forget to up-vote the answers that you feel are best, and give the green checkmarks to those that you feel are the correct ones.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:

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.