title: Alerts set on a timer but only if box is checked
body: <p>I need an alert to pop up at a given minute past every hour, but only if a box is checked. Keep in mind everything in the here needs to be duplicated as on <a href="http://www.jaggedcommandos.net/MRTimers2.html" rel="nofollow noreferrer">this page</a>. I seem to have the timers working, but for the last 2 days I have been unable to make the alerts only happen if the box is checked for each individual city.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>window.onload = function() {
    var LAA = document.querySelector('input[name=LAAlert]');
    var d = new Date();
    var Gamehours = d.getUTCHours();
    var Gameminutes = d.getUTCMinutes();
    var Gameseconds = d.getUTCSeconds();
    //LA Variables
  
  
    function check() {
      var LAcheck;
      var LACoke = "20";
      var LAHeroin = "0";
      var LABarbs = "05";
      var LAUntilcoke = LACoke - Gameminutes;
      var LANextcoke = LAUntilcoke + 60;
      var LAUntilheroin = 60 - Gameminutes;
      var LAUntilbarb = LABarbs - Gameminutes;
      var LANextbarb = LAUntilbarb + 60;
      if (LAA.checked) {
        LAcheck = "checked";
      } else {
        LAcheck = "not checked";
      }
      document.getElementById('LAAresult').innerHTML = 'LA Alerts ' + LAcheck;
  
      //LA Timer Alerts
      if (LAcheck == "checked" &amp;&amp; Gameminutes == LACoke &amp;&amp; Gameseconds == "00") {
        window.alert("The Price of Cocaine in LA has changed")
      };
  
      if (LAcheck == "checked" &amp;&amp; Gameminutes == LAHeroin &amp;&amp; Gameseconds == "00") {
        window.alert("The Price of Heroin in LA has changed")
      };
  
      if (LAcheck == "checked" &amp;&amp; Gameminutes == LABarbs) {
        window.alert("The Price of Barbituates in LA has changed")
      };
    }
    LAA.onchange = check;
    check();
  }
  
  
  var myVar = setInterval(function() {
    myTimer()
  }, 1000);
  
  function myTimer() {
    var d = new Date();
    var Gamehours = d.getUTCHours();
    var Gameminutes = d.getUTCMinutes();
    var Gameseconds = d.getUTCSeconds();
    var Countdown = 60 - Gameseconds;
  
    //LA Variables
    var LACoke = "20";
    var LAHeroin = "00";
    var LABarbs = "05";
    var LAUntilcoke = LACoke - Gameminutes;
    var LANextcoke = LAUntilcoke + 60;
    var LAUntilheroin = 60 - Gameminutes;
    var LAUntilbarb = LABarbs - Gameminutes;
    var LANextbarb = LAUntilbarb + 60;
  
  
  
    //Display In-game time
    document.getElementById("gametime").innerHTML = "Time: " + Gamehours + ":" + Gameminutes + ":" + Gameseconds;
    //LA Timers     
  
    //Display Cocaine price change time remaining
    if (LACoke &gt; Gameminutes) {
      document.getElementById("LAcoketime").innerHTML = "Cocaine: " + LAUntilcoke + ":" + Countdown;
    } else if (LACoke &lt; Gameminutes) {
      document.getElementById("LAcoketime").innerHTML = "Cocaine: " + LANextcoke + ":" + Countdown;
    } else if (LACoke == Gameminutes) {
      document.getElementById("LAcoketime").innerHTML = "Cocaine: CHANGED";
    };
  
  
    //Display Heroin price change time remaining
    if (LAHeroin &lt; Gameminutes) {
      document.getElementById("LAherointime").innerHTML = "Heroin: " + LAUntilheroin + ":" + Countdown;
    } else if (LAHeroin == Gameminutes) {
      document.getElementById("LAherointime").innerHTML = "Heroin: CHANGED";
    };
  
  
    //Display Cocaine price change time remaining
    if (LABarbs &lt; Gameminutes) {
      document.getElementById("LAbarbtime").innerHTML = "Barbituates: " + LANextbarb + ":" + Countdown;
    } else if (LABarbs == Gameminutes) {
      document.getElementById("LAbarbtime").innerHTML = "Barbituates: CHANGED";
    } else if (LABarbs &gt; Gameminutes) {
      document.getElementById("LAbarbtime").innerHTML = "Barbituates: " + LAUntilbarb + ":" + Countdown;
    };
  
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;p id="gametime"&gt;&lt;/p&gt;
  &lt;input name="LAAlert" id="LAALert" type="checkbox" value="1"&gt;&lt;span id="LAAresult"&gt;&lt;/span&gt;
  &lt;p id="LAbarbtime"&gt;&lt;/p&gt;
  &lt;p id="LAherointime"&gt;&lt;/p&gt;
  &lt;p id="LAcoketime"&gt;&lt;/p&gt;
  &lt;br&gt;</code></pre>
  </div>
  </div>
  </p>