Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 26th, 2012  |  syntax: None  |  size: 1.01 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. onclick checkbox event
  2. $(document).ready(function() {  
  3.     var url = 'http://mysite.com/results.aspx';  
  4.         $('.LocType').click (function ()
  5.             {
  6.                 var thisCheck = $(this);
  7.             if (thischeck.is (':checked'))
  8.              {
  9.             // Do stuff
  10.              window.location.href = "http://www.yahoo.com";  
  11.  
  12.              }
  13.         });
  14. });
  15.  
  16. <div class="MyOptions">
  17.     Hospitals<input class="LocType" type="checkbox" value="Hospital"/> &#160;  
  18.     Offices<input class="LocType" type="checkbox" value="Office"/> &#160;  
  19.     Facilities<input class="LocType" type="checkbox" value="Facility"/>
  20. </div>
  21.        
  22. $('.LocType').click (function () {
  23.    if (this.checked) {
  24.        // Do stuff
  25.        window.location.href = "http://www.yahoo.com?paramNameHere=" + this.value;
  26.    }
  27. });
  28.        
  29. $('.LocType').click (function (e) {
  30.    if (this.checked) {
  31.        // Do stuff
  32.        window.location.href = "http://www.yahoo.com" + e.target.value;
  33.       //e.target is the element that fire up the event
  34.    }
  35. });