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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:41:22+00:00 2026-06-09T16:41:22+00:00

Before we start, I’ve read more than a few other posts here related to

  • 0

Before we start, I’ve read more than a few other posts here related to the topic such as;
How do I disable and re-enable a button in with javascript?
though none of the posts seem to have solved my problem.

I am creating a mobile app in dreamweaver cs6 using html, css and javascript. The app is simple and includes a start and stop button that controls a running timer (This timer will count even while the phone is switched off because it calculates the time difference from datetime values stored in a database.)

What I want is, while the timer is running for the start button to be disabled and the stop button to be enabled and when the timer is not running for this to be reversed. I have tried several methods below which work to varying degrees.

function runningTimer()
{
var timerStarted = localStorage.getItem("timerStarted");    
if (timerStarted == "true")
{   
    document.getElementById("runningTime").style.color="#00CC00";
    document.getElementById("stopButton").removeAttribute('disabled');
    document.getElementById("startButton").setAttribute("disabled", "disabled");

db.transaction(function(tx) {
    tx.executeSql("SELECT * FROM temp WHERE tempID=?", [1], function(tx, result) {
        for (var i = 0; i < result.rows.length; ++i) {
            var row = result.rows.item(i);
            var sqlStartTime = row['startTime'];
            }
        if (!result.rows.length)
        {
            alert("Error Code 420: Start Time not found.");
        }
    var currentTime = new Date();
    var jsStartTime = convertSQLtoJS(sqlStartTime);
    var shiftTimeMS = currentTime - jsStartTime;
    var shiftTime = new Date(null, null, null, null, null, null, shiftTimeMS);
    var shiftHours = shiftTime.getHours();
    if (shiftHours < 10)
        {
            shiftHours = "0" + shiftHours;
        }
    var shiftMinutes = shiftTime.getMinutes();
    if (shiftMinutes < 10)
        {
            shiftMinutes = "0" + shiftMinutes;
        }
    var shiftSeconds = shiftTime.getSeconds();
    if (shiftSeconds < 10)
        {
            shiftSeconds = "0" + shiftSeconds;
        }
        document.getElementById("runningTime").innerHTML = (shiftHours + ":" + shiftMinutes + ":" + shiftSeconds);
      });
});
}
else if (timerStarted == "false")
{
    document.getElementById("runningTime").style.color="#FF0000";
    document.getElementById("stopButton").setAttribute("disabled", "disabled");
    document.getElementById("startButton").removeAttribute('disabled'); 
}
else
{
    document.getElementById("stopButton").setAttribute("disabled", "disabled");
    document.getElementById("startButton").removeAttribute('disabled');
}

}

The above code does not function the first time you use it. Either the stop or start button is disabled correctly at the start (Depending on weather or not the timer is already running when the page / app is loaded.) But once you click stop or start it does not re-enable the buttons until you refresh the page in browser or close and reopen the app on a smartphone. So, I added an onClick page load to both the start and stop buttons which works perfectly in Google Chrome however it does not work on the the smartphone.

I have also tried the following which did not work correctly either;

document.getElementById("stopButton").disabled=true;
document.getElementById("startButton").disabled=false;

I’ve had a few friends look over the code for me, and everybody seems to think it should work so we are all scratching our heads on what could be the problem as once you reload the page once everything works perfectly.

Any help would be fantastic and I’m sure I’ve just done something stupid, but please do let me know!

Kind regards,
Mitchell Ransom

  • 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-09T16:41:24+00:00Added an answer on June 9, 2026 at 4:41 pm

    Ok its been a while since I asked this and I am still no closer to figuring it out. I decided to remove the function completely. Not really an answer but since there seems to be no solution its the only answer to be able to move on with the rest of the project.

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

Sidebar

Related Questions

Before start work on implementation Model layout, I ask few question on this site:
Before start let me tell my experience: I am experienced with C#.NET, web services,
I want to get one record before start date and end date DtpFrom means
Am using Mediainfo library in my C# project,before start invoking this dll,i just ran
I usually try to do TDD with not much analysis (no diagrams) before start
I am working on a Media up-loader which uploads images to Server. Before start
before I start I want to point out that I tagged this question as
(Before I start, yes I have asked a similar question before; unfortunately due to
Before I start, I want to make it clear that my code is working
Before i start, i know the MD5 is compromised (collision attack and speed of

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.