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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:11:32+00:00 2026-05-28T05:11:32+00:00

Okay, so there is a button on a page that I’m trying to change

  • 0

Okay, so there is a button on a page that I’m trying to change the text of for a count-down done in Javascript. I’m fairly new to the language (2 days), and am not sure as to what is wrong with my code. Instead of waiting the full second before iterating again, it instantly re-iterates.

var c = 15;
function countDown(e){
  if (c!=0){
     e.value = 'Reply (' + c + ')';
     c--;
     setTimeout(countdown(e),1000);
  }
  else{
     e.value = 'Reply'}
  }
}

but it seems that instead of taking 15 seconds like I assumed, it fires off all at once (proven by me adding in an alert('a'); in the if statement I could see the button text changing)

I’m not sure if it’s a problem with Greasemonkey or a problem with my javascript.

  • 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-05-28T05:11:33+00:00Added an answer on May 28, 2026 at 5:11 am

    Your problem is with this line:

    setTimeout(countdown(e),1000);
    

    countdown(e) is a call to the countdown function that returns void. The setTimeout function accepts a function reference and a timeout, so you need to change it to:

    setTimeout(countdown, 1000);
    

    Your current code is calling countdown(e) 15 times recursively and then setTimeout(void, 1000);

    If you need setTimeout to pass arguments (like e) to your function you can make use of the optional parameters after the timeout.

    setTimeout(countdown, 1000, e);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, okay. There's Visual Studio 2008 and Embarcadero Delphi/Studio that are both able to
Okay, i have a simple button on my page (MyPage) which fades out the
I'm new to android but I've done the notepad tutorial. Now I'm trying to
Okay, There seems to be a lot of discussion on here about how terribly
Okay, here's the scenario. I have a utility that processes tons of records, and
Okay, I have looked everywhere and tried almost every suggestion that I could find
Okay, I'm still new to the whole ASP.NET and exactly how it posts back
Okay, here is my situation. I have a page, index.php, which is the mainsite
Okay, I've seen the webpage that shows you how to enter a decimal key
Okay, Here are three Facebook URLs: http://facebook.com/about [A Facebook Page] http://facebook.com/zuck [Zuckerberg's Profile] http://facebook.com/like

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.