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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:40:23+00:00 2026-06-13T10:40:23+00:00

I have a tiny php file which has only a div and a countdown

  • 0

I have a tiny php file which has only a div and a countdown javascript on it. Here is the code:

        <b><div id="COUNTER"></div></b>
        <SCRIPT type="text/javascript">
        var TargetCOUNTER = document.getElementById('COUNTER');
        //HIER DIE SEKUNDEN EINTRAGEN HERR REUTER !!
        var SecondsCOUNTER = 5654;
        //------------------------------------------
        var TargetTimeCOUNTER = new Date();
        var TimeBeginnCOUNTER = TargetTimeCOUNTER.getTime();
        var TimeEndCOUNTER = TimeBeginnCOUNTER + (SecondsCOUNTER*1000);
        TargetTimeCOUNTER.setTime(TimeEndCOUNTER);

        var DayCOUNTER = TargetTimeCOUNTER.getDate();
        var MonthCOUNTER = TargetTimeCOUNTER.getMonth() + 1;
        var YearCOUNTER = TargetTimeCOUNTER.getYear();
        if(YearCOUNTER < 999) YearCOUNTER += 1900;
        var hCOUNTER = TargetTimeCOUNTER.getHours();
        var mCOUNTER = TargetTimeCOUNTER.getMinutes();
        var sCOUNTER = TargetTimeCOUNTER.getSeconds();

        var fdayCOUNTER  = ((DayCOUNTER < 10) ? "0" : "");
        var fmonthCOUNTER  = ((MonthCOUNTER < 10) ? ".0" : ".");
        var fhCOUNTER  = ((hCOUNTER < 10) ? "0" : "");
        var fmCOUNTER  = ((mCOUNTER < 10) ? ":0" : ":");
        var fsCOUNTER  = ((sCOUNTER < 10) ? ":0" : ":");

        var EndDateCOUNTER = fdayCOUNTER + DayCOUNTER + fmonthCOUNTER + MonthCOUNTER  + "." + YearCOUNTER;
        var EndTimeCOUNTER = fhCOUNTER+hCOUNTER+fmCOUNTER+mCOUNTER+fsCOUNTER+sCOUNTER;

        CountDownCOUNTER();
        function CountDownCOUNTER() {
            var CurrentDateCOUNTER = new Date();
            var CurrentTimeCOUNTER = CurrentDateCOUNTER.getTime()
            var OpenTimeCOUNTER = Math.floor((TargetTimeCOUNTER-     CurrentTimeCOUNTER)/1000);

            var sCOUNTER = OpenTimeCOUNTER % 60;
            var mCOUNTER = ((OpenTimeCOUNTER-sCOUNTER)/60) % 60;
            var hCOUNTER = ((OpenTimeCOUNTER-sCOUNTER-mCOUNTER*60)/(60*60));
            var fhCOUNTER  = ((hCOUNTER < 10) ? "0" : "");
            var fmCOUNTER  = ((mCOUNTER < 10) ? ":0" : ":");
            var fsCOUNTER  = ((sCOUNTER < 10) ? ":0" : ":");

            var TimeCOUNTER = fhCOUNTER+hCOUNTER+fmCOUNTER+mCOUNTER+fsCOUNTER+sCOUNTER;
            var OutputStringCOUNTER=TimeCOUNTER;

            if(OpenTimeCOUNTER<=0) { // Event wenn der Countdown abgelaufen ist
                OutputStringCOUNTER="<a href='../hackerz/fight.php' style='text-decoration: none; color: #00ff00'>Aktualisieren</a>";
            }

            TargetCOUNTER.innerHTML=OutputStringCOUNTER; // Ausgabe des Strings in der Betreffenden Zelle
            document.title=(OutputStringCOUNTER.substring(0,2)=="<a")?"!!!READY!!!":OutputStringCOUNTER;
            window.setTimeout("CountDownCOUNTER()",1000);
        }
    </SCRIPT>

It works very well. You can check it out here: http://dev.willstequatschen.de/hw/sites/hackerz/counter.php

But I want to display 2 rows with different counters, when I copy and paste the code tiwce, the second counter is not displayed. Why is that?

  • 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-13T10:40:24+00:00Added an answer on June 13, 2026 at 10:40 am

    Wrap all your code in a single function accepting an id of the counter container:

    function setCounter(id) {
        var TargetCOUNTER = document.getElementById(id);
        // rest of your code here
    }
    

    Call this function for each counter separately:

    setCounter('COUNTER1');
    setCounter('COUNTER2');
    

    See demo http://jsfiddle.net/dfsq/CdeGs/

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

Sidebar

Related Questions

I'm trying to create a mosaic type script in Javascript and PHP, which makes
I have a tiny javascript which uses JQUERY UI. When I get the 'drop'
I have nginx receiving POST requests and a tiny PHP script that puts request
I have this simple code in php: <?php header(Content-type: application/vnd.ms-word); header(Content-Disposition: attachment;Filename=kid_tag.doc); echo '<table
Under plain PHP 5.3, I have some code which uses MySQL to first deletes
So I have a tiny problem. I got help here a while ago about
So, I have a tiny fragment of C code running on a windows box,
I am new to php and sql, and i have one tiny question about
This is my problem, I have a tiny PHP MVC framework i built. Now
I have made a tiny ModX snippet that looks like this <?php $theMenu =

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.