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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:19:44+00:00 2026-06-15T21:19:44+00:00

(second.innerHTML) -1 that worked but (num.innerHTML) -1 that not working why? function doDcrements() {

  • 0

(second.innerHTML) -1 that worked but (num.innerHTML) -1 that not working why?

function doDcrements() {
     var hidden = document.getElementById('hidden');
     var second = document.getElementById('second');  // the second is 20.
     var loopTimer = 0;
     if (second.innerHTML != "0") {
         second.innerHTML = (second.innerHTML) -1;
         second.style.color = "blue";
         loopTimer = setTimeout('doDecrements()',1000);
     }else {
         second.style.color = "grey"; 
         hidden.style.display = "block";   
     }
 } 

…………………………………………………………………………………………………………………………………………………

function doDcrements() {
         var hidden = document.getElementById('hidden');
         var second = document.getElementById('second'); // the second is 20. 
         var loopTimer = 0; 
         var num = document.getElementById('num'); // the number is 20. 
         if (second.innerHTML != "0") {
             second.innerHTML = (num.innerHTML) -1;
             second.style.color = "blue";
             loopTimer = setTimeout('doDecrements()',1000);
         }else {
             second.style.color = "grey";  
             hidden.style.display = "block";   
         }
     } 

when I create it by for loop it not happens :

function doDcrements() {
    var hidden = document.getElementById('hidden');
    var second = document.getElementById('second');
    for (i=20; i<=0; i--) {
           if (second.innerHTML != "0") {
             second.innerHTML = i;
             second.style.color = "blue";
             loopTimer = setTimeout('doDecrements()',1000);
         }else {
             second.style.color = "grey";  
             hidden.style.display = "block";   
         }
    }
}

html code:

<div id="hidden">started</div>
<p id="second">20</p>
<div onClick="doDcrements();">Download</div> 
  • 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-15T21:19:46+00:00Added an answer on June 15, 2026 at 9:19 pm

    (second.innerHTML) -1 that worked but (num.innerHTML) -1 that not working why?

    Without seeing your code, the only guess is that num.innerHTML is not giving you a string that is convertible to number. Examples:

    '20' - 1 = 20

    '<input name="xyz" val="20"/>' - 1 = NaN

    Your HTML does’t have any element with id=”num”. If this is the case, num will be null.

    Changes
    setTimeout(doDecrements,1000);
    for (i=20; i >=0; i--)

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

Sidebar

Related Questions

the second function isnt working? $('.edit_hover').live('hover', function(e){ $(this).stop(); var half_width = ($(this).css('width').slice(0, -2))/2; var
It appears that second windows are not closing. Here is what I am doing....
I'm trying to recreate the following code with jQuery: var node = document.createElement(div); node.innerHTML
Second question of the day but hopefully simple, I just need to change the
the second function gives error C2803 http://msdn.microsoft.com/en-us/library/zy7kx46x%28VS.80%29.aspx : 'operator ,' must have at least
What's the second minimum value that a decimal can represent? That is the value
I am trying to pass a variable to a a function that I believe
a[b].innerHTML=a[b].innerHTML.replace(RegExp('['+bbc[c][0]+']','ig'),bbc[c][1]) This is basically what I'm working with. It's wrapped in two loops so
I have a JS function that processes XML I GET from a server to
I have a simple script that i am testing with, but its acting very

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.