Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

680
Views
Uncaught ReferenceError: myfunction() is not defined at HTMLButtonElement.onclick

The purpose is: when user search any keyword in Google of my site, this button will show. When click this button will show code.

The error show like:

Uncaught ReferenceError: startcountdown is not defined at HTMLButtonElement.onclick

I was define startcountdown function before call it. Can anyone help me? Many thanks.

var referrer = document.referrer;
ifm_list_browser = ['google.com', 'google.com.vn'];

function checkFefer(f, e) {
  var i = 0;
  for (i = 0; i < e.length; i++) {
    if (f.indexOf(e[i]) > -1) return true;
  }

  return false;
}

function startcountdown() {
  document.getElementById('countDown40').setAttribute("style", "background: #0b1df5;border-radius: 10px;border:none;color: #ffffff;width: 59%;padding: 10px 0;text-transform: uppercase;font-weight: bold;font-size: 16px;outline: none; cursor: pointer;");
  let cNode = jQuery("#references40");
  let cKey = cNode.attr('code-ref');
  let cCount = cNode.attr('countdown');
  let counter = parseInt(cCount) || 40;
  var countdownCode = setInterval(function() {
    counter--;
    document.getElementById('countDown40').innerHTML = 'The code will show ' + counter + ' second' + '... Waiting...';
    if (counter == 0) {
      document.getElementById('countDown40').innerHTML = `Your code is: ${stores[cKey]}`;
      document.getElementById('countDown40').setAttribute("style", "background: #ea3b7b;border-radius: 10px;border:none;color: #ffffff;width: 59%;padding: 10px 0;text-transform: uppercase;font-weight: bold;font-size: 16px;outline: none; cursor: pointer;");
      clearInterval(countdownCode);
      return false;
    }
  }, 1000);
}

let stores = {
  'ref48': '12344',
  'ref49': 'some thing',
  'ref50': 'happy polla',
  'ref51': '343596',
}

var flagref = checkFefer(referrer, ifm_list_browser)
if (flagref) {
  var html = '<p style="text-align:center;"><button style="background: #e81e1e;border-radius: 10px;border:none;color: #ffffff;width: 59%;padding: 10px 0;text-transform: uppercase;font-weight: bold;font-size: 16px;outline: none; cursor: pointer;" id="countDown40" get-code="true" class="coundownmobile" onclick="startcountdown(); this.onclick=null;">Get code</button></p>';
  jQuery(document).ready(function($) {
    $("#references40").empty();
    html = $.parseHTML(html);
    $("#references40").append(html);
  });

}
<div id="references40" code-ref="ref51" countdown="8" style="text-align: center; font-weight: 600;"> Button will appear when search in Google </div>

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!