Welcome to BeerMoneyForum.com - BIGGEST MAKE MONEY FORUM ONLINE

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?
Blue
Red
Green
Orange
Voilet
Slate
Dark
  Guest viewing is limited

Must checkout:

❓ASK Need some help creating my first html+js page

B

bigmim_aka_Mauro

Guest

Obviously I am beginner especially with javascript.
Anyway I enclose the code I made. In the table there are three columns, the first reserved for the links to visit, the second reserved for the time that must pass before the next visit, the third reserved for the countdown. Then by clicking on the link in col.1 you should be redirected to the corresponding web page (in a new tab) while, at the same time, a countdown starts which takes the time indicated in col.2 and shows it in col.3 (expressed in hh : mm: ss); when it reaches 0, the word "ready" should appear, but it is also okay that it remains at 0.
I think my script needs some help with adding event listeners to each link, and getting the countdown to start and show up in column 3.
Thanks in advance to those who will help me.

HTML:
<html>
<head>
    <style type="text/css">
        body {
  background-color:#7B68EE;
  font-family: "Arial Rounded MT","Liberation Serif", "School Times","Times New Roman";
  color:black;
  font-weight:200;
  font-size:110%
}
.centered table {
  margin: 0 auto;
}
table {
  width: 750px;
  border: 4px solid #000000;
  border-collapse: collapse
}
td {
  width: 250px;
  height: 40px;
  border:1px solid black;
  padding: .1em
  }
td:nth-child(2)  {
  text-align:center
  }
td:nth-child(3)  {
  text-align:center
  } 
a:link{
  color:black;
  text-decoration:none;
  font-weight:bolder
}
a:visited {
  color: black;
  text-decoration:none;
}
a:hover {
  color: red;
  text-decoration:blink
}
a:active{
  color: green;
  text-decoration:underline
}
    </style>
    <script src="/scripts/snippet-javascript-console.min.js?v=1"></script>
</head>
<body>
    <table>
  <tbody>
    <tr>
      <th>site
      </th>
      <th>time
      </th>
      <th>countdown
      </th>
    </tr>
    <tr>
      <td>
        <a href="http://www.google.com" id="url" onclick="startTimer()" target="_blank">
          Google
        </a>
      </td>
      <td class="time">01:30
      </td>
      <td class="countdown">
      </td>

    </tr>
    <tr>
      <td>
        <a href="http://www.apple.com" id="url" onclick="startTimer()" target="_blank">
          Apple
        </a>
      </td>
      <td class="time">00:30
      </td>
      <td class="countdown">
      </td>
    </tr>
    <tr>
      <td>
        <a href="http://www.microsoft.com" id="url" onclick="startTimer()" target="_blank">
          Microsoft
        </a>
      </td>
      <td class="time">02:15
      </td>
      <td class="countdown">
      </td>
    </tr>
  </tbody>
</table>
    
</body>
</html>

JavaScript:
document.querySelectorAll('table td a').forEach(link => {
        link.addEventListener('click', event => {
            event.preventDefault();
            const row = link.parentNode.parentNode;
            const url = link.href;
            const time = row.querySelector('.time');
            const countdown = row.querySelector('.countdown');
            console.log(url, time.classList, countdown.classList);
            })
    });
startTimer = () => {

window.open(url.href, '_blank');

let tiks = setInterval(countdown, 1000);

link.style.color = 'red';
count.style.color = 'red';

function countdown() {
if (secs == -1) {
clearInterval(tiks)
link.style.color = 'green';
time.style.color = 'green';
count.style.color = 'green';
} else {
count.innerHTML = secs; secs–;
}
}
}
 

📢 Recommended Partners

Paykassma - Accept Payments Online  | Payment Processing since 2019 Payka$$ma
Leading solution for accepting high-risk payments since 2019
5.00 star(s) 1 ratings
Updated
MGID - Native Performance & Programmatic Advertising Platform MGID Team
0.00 star(s) 0 ratings
Updated
Roobet.com | Crypto’s Fastest Growing Casino 🦘 Roobet.com
1.00 star(s) 1 ratings
Updated
Duckdice.io - Top Crypto Gambling - Bitcoin Dice DuckDice.io
0.00 star(s) 0 ratings
Updated

banner

REWARDS: Active Raffles


  • 🤑 Roll 4: Win 100,000 BMF Points!

    The entry period for this raffle ends in..
Back
Top Bottom

Earnings Disclaimer:  All the posts published herein are merely based on individual views, and they do not expressly or by implications represent those of BeerMoneyForum.com or its owner. It is hereby made clear that BeerMoneyForum.com does not endorse, support, adopt or vouch any views, programs and/or business opportunities posted herein. BeerMoneyForum.com also does not give and/or offer any investment advice to any members and/or it's readers. All members and readers are advised to independently consult their own consultants, lawyers and/or families before making any investment and/or business decisions. This forum is merely a place for general discussions. It is hereby agreed by all members and/or readers that BeerMoneyForum.com is in no way responsible and/or liable for any damages and/or losses suffered by anyone of you.