title: Send checkbox values through ajax for a php/mysql query
body: <p>I am creating an html form and using it's values to dynamically filter search results from a mysql database. I have several dropdown's and one checkbox field for multiple values and I cannot get the checked values to send over ajax to my php page. Is there a way to update my query results based on this checkbox field the same way it current is for the other select fields?</p>
  
  <p>HTML Code:</p>
  
  <pre><code>&lt;form name="searchForm"&gt;
      &lt;input type="checkbox" name="services" value="twic" onclick="get_check_value()"&gt;TWIC&lt;/input&gt;&lt;br/&gt;&lt;/li&gt;
      &lt;input type="checkbox" name="services" value="enclosedTrucking" onclick="get_check_value()"&gt;Enclosed Trucking&lt;/input&gt;&lt;br/&gt;
      &lt;input type="checkbox" name="services" value="flatBedTrucking" onclick="get_check_value()"&gt;Flat Bed Trucking&lt;/input&gt;&lt;br/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Java script:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function get_check_value()
      {
          var c_value = "";
          for (var i=0; i &lt; document.searchForm.services.length; i++) {
              if (document.searchForm.services[i].checked) 
              {
                  c_value = c_value + document.searchForm.services[i].value + "\n";
              }
          }
          return = c_value;
          //alert(c_value);
      }
  &lt;/script&gt;
  &lt;script language="javascript" type="text/javascript"&gt;
      //Browser Support Code
      function ajaxFunction(){
          var ajaxRequest;  // The variable that makes Ajax possible!
          try{
              // Opera 8.0+, Firefox, Safari
              ajaxRequest = new XMLHttpRequest();
          }catch (e){
              // Internet Explorer Browsers
              try{
                  ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
              }catch (e) {
                  try{
                      ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
                  }catch (e){
                      // Something went wrong
                      alert("Your browser broke!");
                      return false;
                  }
              }
          }
          // Create a function that will receive data 
          // sent from the server and will update
          // div section in the same page.
          ajaxRequest.onreadystatechange = function(){
              if(ajaxRequest.readyState == 4){
                  var ajaxDisplay = document.getElementById('results');
                  ajaxDisplay.innerHTML = ajaxRequest.responseText;
              }
          }
          // Now get the value from user and pass it to
          // server script.
          var os = document.getElementById('originState').value;
          var c = document.getElementById('commodity').value;
          var ds = document.getElementById('destState').value;
          var ser = c_value;
          var queryString = "?os=" + os ;
          queryString +=  "&amp;c=" + c + "&amp;ds=" + ds + "&amp;ser=" + ser;
          //ajaxRequest.open("GET", "php/search2.php" + 
          //                           queryString, true);
          ajaxRequest.open("GET", "php/testqueries.php" + queryString, true);
          ajaxRequest.send(null); 
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>PHP to receive the variables:</p>
  
  <pre><code>$ser = $_GET['ser'];
  </code></pre>