title: Form redirect on checkbox selection
body: <p>Here's what i'm trying to achieve: I want to create a HTML page with a form, when you submit the form it goes to 1 of 4 locations. There is a default hidden main option thats auto-selected on page load and 2 sub-options that are optional.</p>
  
  <p>Oh, and it calculates the amounts on selection!</p>
  
  <p>Here's my code so far:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
  
  &lt;form onSubmit="submitForm();" id="myForm" type="get"&gt;
  &lt;input id="myCheckbox1" name="myCheckbox1" type="checkbox" value="20" onClick="calcNow();" /&gt;Default option&lt;br/&gt;
  &lt;input id="myCheckbox2" name="myCheckbox2" type="checkbox" value="30" onClick="calcNow();" /&gt;Add-on option 1&lt;br/&gt;
  &lt;input id="myCheckbox2" name="myCheckbox2" type="checkbox" value="40" onClick="calcNow();" /&gt;Add-on option 2&lt;br/&gt;
  &lt;input id="myTotal" name="myTotal" type="text" value="" disabled="disabled" /&gt;&lt;br/&gt;
  &lt;input type="button" id="myButton" onClick="submitForm();" value="Continue" /&gt;
  &lt;/form&gt;
  
  &lt;script type="text/javascript"&gt;
  var pages = [[["http://mysite.com/page1.html"],["http://mysite.com/page2.html"],["http://mysite.com/page3.html","http://mysite.com/page4.html"]]];
  
  function calcNow()
  {
      var cb = document.getElementById("myCheckbox1");
      var cb = document.getElementById("myCheckbox2");
      var cost1 = cb.checked ? parseInt(cb.value) : 0;
      var cost2 = cb.checked ? parseInt(cb.value) : 0;
      var costTotal = cost1 + cost2;
      document.getElementById("myTotal").value = costTotal;
  
      var op1 = cb.checked ? 1 : 0;
  
      if (op1 != undefined)
      {
          return pages[op1];
      }
      return undefined;
  }
  
  function submitForm()
  {
      var page = calcNow();
      if (page != undefined)
      {
          alert(page);
          // ---- To navigate ----
          //location.href = page;
          // ---- To alter post ----
          //var form = document.getElementById("myForm");
          //form.action = page;
          //form.submit();
      }
      else
      {
          alert("Please answer all questions.");
      }
  }
  
  function getRadioValue(name)
  {
    var controls = document.getElementsByName(name);
    for (var i = 0; i &lt; controls.length; i++) {
        if (controls[i].checked) {
            return parseInt(controls[i].value);
        }
    }
    return 0;
  }
  
  function getRadioData(name, attribute)
  {
    var controls = document.getElementsByName(name);
    for (var i = 0; i &lt; controls.length; i++) {
        if (controls[i].checked) {
            return parseInt(controls[i].dataset[attribute]);
        }
    }
    return undefined;
  }
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>