[jQuery] Re: toggling checkboxes in an adjacent table cell

2007-04-05 Thread Roman Weich


RwL schrieb:

I'm pretty new to jQuery and have hit the wall on this one... I have a
tabular form where data points can be selected for update or to be
ignored, sample here:

http://www.lifford.org/exp/jQuery-checkboxes.html

It was extremely easy to set up the select all / deselect all toggle
at the top on a link to check/uncheck every box in every row. The next
requirement, though, is what's tripping me up: I need the single
checkbox in the last cell of each row to check or uncheck all the
checkboxes in the adjacent (previous) cell, to match its own state. I
don't think I can just use toggle() because the initial state of that
checkbox could have been altered already by the master toggle above
the table -- I think this needs to check for the state of the checkbox
after the change and then force the others to match it.

I've searched around and looked at / played with some forms plugins
but none seem to help me get near accomplishing this specific task.

Any pointers?



How about this?

$('input.rowChecker').click(function(){
$(this).parent().siblings('.updateItems').find('[EMAIL PROTECTED]').attr('checked', 
this.checked);

});

Cheers,
/rw


[jQuery] Re: toggling checkboxes in an adjacent table cell

2007-04-05 Thread Glen Lipka

On 4/5/07, RwL [EMAIL PROTECTED] wrote:



 How about this?

 $('input.rowChecker').click(function(){

$(this).parent().siblings('.updateItems').find('[EMAIL 
PROTECTED]').attr('checked',

 this.checked);

 });




Another possibility:

 $(table tr td:last-child input).click(function(){
$(../../td [EMAIL PROTECTED], this).attr(checked, this.checked
);
   }
 )

This way you wouldn't need classes on the last one or the inner ones.  This
is my first working xPath sample.  I think it could be even shorter.

Glen