title: Button click redirect if code is right
body: <p>I am trying to set it up so that there are two buttons. A 'checkout' button and a 'checkout with code' button. If you hit the 'checkout' button, you're redirected to a page. I have that done with no problems at all. </p>
  
  <p>For the 'checkout with code' button, if the code is right, you'll be redirected to a different page. If the code is wrong, an alert will come up and say "Invalid Code". I don't know how to make the button redirect you to the second page if you get the code right.</p>
  
  <p>Here's my coding:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;script type='text/javascript'&gt;
      //this is the code that is used to checkout, when you press the checkout with code button.
      var code = 123456
      //if code is right, redirect to page2
      function checkOut2 () {
          if (code = 123456) {window.location.pathname = "nintendo.com"} else {
              alert("Invalid Code");
          }
      }
  &lt;/script&gt;
  &lt;html&gt;
      &lt;body&gt;
          &lt;button type="button" onclick="location.href = 'www.yoursite1.com'" id="checkOut"&gt;Checkout&lt;/button&gt;
          &lt;br&gt;
          &lt;br&gt;
          &lt;button type="button" id="checkOut2"&gt;Checkout With Code&lt;/button&gt;
          &lt;br&gt;
          Code:
          &lt;input type="text" name="code"&gt;
          &lt;br&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>So, when you press the Checkout With Code button and have a valid code in the Code textbox, you'd be redirected to nintendo.com. But I have no idea how to make this work properly..</p>