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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:12:58+00:00 2026-06-08T22:12:58+00:00

I want to use a countdown script like this var montharray=new Array(Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec) function countdown(yr,m,d,idCountdown){

  • 0

I want to use a countdown script like this

     var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

function countdown(yr,m,d,idCountdown){
    var theyear=yr;
    var themonth=m;
    var theday=d;
    var today=new Date();
    var todayy=today.getYear();
    if (todayy < 1000)
        todayy+=1900
    var todaym=today.getMonth();
    var todayd=today.getDate();
    var todayh=today.getHours();
    var todaymin=today.getMinutes();
    var todaysec=today.getSeconds();
    var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec;
    var futurestring=montharray[m-1]+" "+d+", "+yr;
    var dd=Date.parse(futurestring)-Date.parse(todaystring);
    var dday=Math.floor(dd/(60*60*1000*24)*1);
    var dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1);
    var dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
    var dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
    var dag = "dagen";

    if(dday==0&&dhour==0&&dmin==0&&dsec==1){
        document.getElementById(idCountdown).value=current;
        return;
    }
    else if(dday<=1) {
        dag = 'dag';
    }
    document.getElementById(idCountdown).value=dday+ ' ' + dag + ' ' +dhour+" uur "+dmin+" min "+dsec+" sec";
    setTimeout(function(){countdown(theyear,themonth,theday,idCountdown);}, 1000);
}

in my html page i will have a textfield like this

 <input name="aktie1" type="text" class="countdownTekst" size="27" readonly="readonly">
 <input name="aktie2" type="text" class="countdownTekst" size="27" readonly="readonly">

Then i use this to use the function

countdown(2012,7,30, 'aktie1')

The last one is the ID for the textfield. But when i do it like this i will get an error

 document.forms.count.idCountdown.value is undefined

How do i get the id for that textfield in that function?

  • 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-08T22:13:00+00:00Added an answer on June 8, 2026 at 10:13 pm

    You need to access the input like this: document.forms.count[idCountdown].value

    EDIT: This fiddle is working http://jsfiddle.net/Fy2FM/4/ . The bigger problem is that you are not declaring the variables with var yourvar, and this makes the variables to be part of the global object. Because of this, you were always seeing the same in both countdowns, because in fact you were accessing the same variables.

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

Sidebar

Related Questions

I want to use a javascript countdown function similar to this http://jsfiddle.net/Apnu2/6/ when a
I want to use a countdown timer in my app. I have this date
I want use php simple xml parse some tree like this. how to plus
I was creating a countdown timer using javascript; I can use jQuery. I want
I want use this 1 for using Bar code or QR code scanner. I
I want to use a simple countdown timer starting at 30 seconds from when
I want use page that has this form: <form method=post action=modules.php?name=search> <input onkeypress=FKeyPress(this); onkeydown=FKeyDown(this);
I want use ajax.net to do some js. like below: ScriptManager.RegisterStartupScript(Submit, typeof(Button), alert, location.href='test.aspx';,
I want use A-Z buttons on a html page like shown below (only sample
<script type=text/javascript> $(function() { var newYear = document.getElementById('HF'); alert('hehe' + newYear); $('#countdown').countdown({ until: newYear,

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.