title: Javascript Checkbox Array with multiple selection results
body: <p>I have a javascript array code my co-worker built. I've fixed it up so depending on the checkbox you select it will go to a designated page (zero.html. zeroone.html etc). What I want to accomplish now is to make it so when you select multiple checkboxes, it will go to another page based on the checkboxes selected.</p>
  
  <p>Here is our code:</p>
  
  <pre><code>&lt;script language="javascript"&gt;
  &lt;!-- Activate Cloaking Device --&gt;
  
  // Set in dataBase() function - used as array index.
  var recnum="";
  // Used to initialize arrays.
  function initArray()
      {
  this.length = initArray.arguments.length;
  for (var i = 0; i &lt; this.length; i++)
      { this[i] = initArray.arguments[i]; }
  }
  // Creating the arrays
  var rcrd = new initArray();
  var address = new initArray();
  address[0] = "zero.html";
  address[1] = "one.html";
  address[2] = "two.html";
  address[0,1] = "zeroone.html";
  address[0,2] = "zerotwo.html";
  address[1,2] = "onetwo.html";
  address[0,1,2] = "zeroonetwo.html";
  
  // Called by onClick for each checkbox button - determines &amp; displays url in full window
  function dataBase(leapto)
  {
  for (var i = 0; i &lt; 4; i++)
      {
      if (leapto.buttons[i].checked)
          { recnum = leapto.buttons[i].value; }
      }
  if ( (rcrd[recnum] !=null) &amp;&amp; (rcrd[recnum] != "") )
      { document.leapto.display.value = rcrd[recnum]+"\r\n\r\n"+address[recnum]; }
  }
  // Called by Search Now button - Loads preselected page.
  
  function leapTo()
  {
  if ( (address[recnum] !=null) &amp;&amp; (address[recnum] != "") &amp;&amp; (recnum != "") )
  window.location= address[recnum];
  else 
      alert("\nYou must make a selection first.");
  }
  // Deactivate Cloaking
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form name="leapto"&gt;
  &lt;input type="checkbox" name="buttons" value="0" onclick="dataBase(this.form)" /&gt; Zero&lt;br /&gt;
  &lt;input type="checkbox" name="buttons" value="1" onclick="dataBase(this.form)" /&gt; One&lt;br /&gt;
  &lt;input type="checkbox" name="buttons" value="2" onclick="dataBase(this.form)" /&gt; Two&lt;br /&gt;
  &lt;input type="button" class="classname" width="400" height="50" border="0" value="Search Now" onclick="leapTo()" /&gt;&lt;/form&gt;
  &lt;script&gt;
  function myFunction(){var x;if (name!=null)  {document.getElementById("demo").innerHTML=x;}}
  &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>