select all rows in table

select all rows in table

Hello,

i'm new to jquery, so i have problem ;) I created this little code for select all rows in table (change of color and check checkbox in row). Problem is when click on checkbox, event is fired and then is event on row is fired too - eg. 2 events fired. I tried to stop bubbling but this causes not to color row and not to check checkbox.

<table>
<tr>
<th>Data</th>
<th><input type="checbox" name="rX' value="" class="fX"></th>
</tr>
<tr>
<td>first</td>
<td><input type="checbox" name="rY[1]' value="" class="fY"></td>
</tr>
<tr>
<td>second</td>
<td><input type="checbox" name="rY[2]' value="" class="fY"></td>
</tr>

javascript code (function chooCheckBox is hooked onload)
function cCheckBox(e) {
   iCnt = $('input.fY').size();
   iOn = $('input.fY:checked').size();
   iOff = iCnt - iOn;
   //alert('DEBUG: ' + iCnt + ' | ' + iOn + ' | ' + iOff);
   if (iOn && !iOff)
      $('input.fX').each(function() {
         this.checked = true;
      })
   else if (!iOn && iOff)
      $('input.fX').each(function() {
         this.checked = false;
      })
}

function chooCheckBox() {
   $('input.fY').click(function(e) {
      $(this).parents('tr')[this.checked ? 'removeClass' : 'addClass']('choo');
      this.checked = !this.checked;
      cCheckBox(e);
   });
   $('input.fX').click(function() {
      x = this.checked;
      $('input.fY').each(function() {
         this.checked = x ? true : false;
         $(this).parents('tr')[x ? 'addClass' : 'removeClass']('choo');
      })
   });
   $('input.fY').parents('tr').click(function(e) {
//      if (e.target.className == 'fY')
//         return true;
      //alert('DEBUG: ' + e.target.className);
      c = false;
      $(this).children('td').children('.fY').each(function() {
         c = this.checked = !this.checked;
      });
      $(this)[c ? 'addClass' : 'removeClass']('choo');
      cCheckBox(e);
   });
}



thank you for help and advices[/code]