title: Ajax checkbox function
body: <p>I am trying to send a checkbox value via ajax to send data to a external function.</p>
  
  <p>I have the function working using the following javascript, however it is very messy as i am currently writing this javascript function for every instance of script which exisits.</p>
  
  <pre><code>&lt;form&gt;
  &lt;input type="checkbox" name="event_status" id="event_status1455" value="1" &lt;?php echo ($event_status == '1' ? 'checked="checked"' : '') ?&gt;&gt;
  &lt;/form&gt;
  
  &lt;form&gt;
  &lt;input type="checkbox" name="event_status" id="event_status1456" value="1" &lt;?php echo ($event_status == '1' ? 'checked="checked"' : '') ?&gt;&gt;
  &lt;/form&gt;
  
  &lt;form&gt;
  &lt;input type="checkbox" name="event_status" id="event_status1457" value="1" &lt;?php echo ($event_status == '1' ? 'checked="checked"' : '') ?&gt;&gt;
  &lt;/form&gt;
  
  &lt;script&gt;
   $('input:checkbox').change(function(e) {
  e.preventDefault();
  var isChecked = $("input:checkbox").is(":checked") ? 1:0; 
  $.ajax({
            type: 'POST',
            url: '&lt;?php echo $this-&gt;url('/profile/list', 'event_status', $cobj-&gt;getCollectionID())?&gt;',
          data: { event_status:$("input:checkbox").attr("id"), event_status:isChecked }
  });        
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>As you can see above the javascript will only respond to this particular checkbox. i cannot figure out how to code it so that i have one javascript function on my page that will run for each checkbox i have.</p>
  
  <p>I Have tweaked the code from my original post. I have my ajax doing what i want, however the ajax function only executes for the last checkbox, is their away i can transform the javascript to to do provide the function for each checkbox?</p>