Why bother with javascript? Html will do it for everyone:

<table>
 <tr>
   <td><label for="check1">cell 1</label></td><td><label for="check1">cell
2</label></td><td><label for="check1">cell 3 </label></td><td><input
id="check1" type="checkbox"></td>
 </tr>

</table>

Mei

On 18/04/07, DaveG <[EMAIL PROTECTED]> wrote:



Just a heads-up, but I recall when I did this that I had to do some
'extra' coding. I'm not sure if you have the same scenario, but I wanted the
row to be highlighted, and the checkbox toggled when either the checkbox was
clicked or the row was clicked. I had to accommodate for the fact that when
the checbox is clicked, the TR trigger also fires, effectively causing a
double fire.

~ ~ Dave

On Wed, 18 Apr 2007 15:03:37 +0100, Howard Jones <[EMAIL PROTECTED]> wrote:
>
> Having just made my first real piece of jQuery code, I'm already
> wondering if it can be made more concise   :-)
>
> It's an unobtrusive mod to an existing page (in Best Practical's RT
> ticketing system). The page has a table of ticket entries, where of the
> TDs in each row is a checkbox. I want to be able to click anywhere on
> the row to toggle the checkbox.
>
> This is my currently working version. Can I attach an event to the
> parent's parent, but have the matching checkbox's ID passed to it, in
> one chain?
>
> $('input:[EMAIL PROTECTED]').each(
>     function() {
>          var myid = $(this).attr('name');
>          $(this).parent().parent().click( function(event) {
>              if(event.originalTarget.tagName != 'INPUT')
>              {
>                  var cb = $('input:[EMAIL PROTECTED]'+myid+']');
>                  cb.attr('checked', !cb.attr('checked'));
>                  return false;
>              }
>         });
>     });
>
> Thanks for any pointers - I'm enjoying adding functionality to RT this
> morning. The ContextMenu plugin has also made an appearance in another
> spot.
>
> Cheers,
>
> Howie


Reply via email to