title: jquery to submit on change checkbox
body: <p>I have the following code, however the problem is that if I use a normal submit button everything works fine, but if I want to submit the checkbox value with jquery onchange it doesn't work (i.e. nothing is going into the db)... I tried even going the non jquery route with an <code>onChange=this.form.submit()</code> appended to construction. Anyone know whats going on/how to fix this? To me it seem like the form is submitting without processing the data. </p>
  
  <p>Also I'm using: <a href="https://github.com/ghinda/css-toggle-switch" rel="nofollow">https://github.com/ghinda/css-toggle-switch</a> for the checkbox</p>
  
  <p>JQUERY:</p>
  
  <pre><code>$('#construction').change(function() {
    this.form.submit();
  });
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>&lt;?php
  $config = mysql_query("SELECT construction FROM config") or die(mysql_error());
  $row_config = mysql_fetch_assoc($config);
  
  if ($_POST) {
      // 0 = off
      // 1 = on
      $constr = $_POST['construction'];
      if ($constr == 'on') { $c = 0; } else { $c = 1; }
      mysql_query("UPDATE config SET construction = '".$c."'") or die(mysql_error());
      redirect('index.php');
  }
  ?&gt;
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div style="margin-top:30px;"&gt;
          &lt;form action="index.php" method="post" id="doSite"&gt;
              &lt;fieldset class="toggle"&gt;
                  &lt;input id="construction" name="construction" type="checkbox"&lt;?php if($row_config['construction'] == '0') { echo ' checked'; } ?&gt;&gt;
                  &lt;label for="construction"&gt;Site construction:&lt;/label&gt;
                  &lt;span class="toggle-button"&gt;&lt;/span&gt;
              &lt;/fieldset&gt;
              &lt;input name="Submit" type="submit" value="Shutdown site" class="button"&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  </code></pre>