Hi Ed,
You're probably better off asking future questions like this in a JavaScript or jQuery forum here at p2p.wrox.com as it's a bit beyond the scope of the book, and of what I can typically support on a forum like this.
Anyway, I quickly cooked up an example as I was a bit intrigued in the solution myself.
Edit: See attachment. This forum was eating my code (due to the call to the jQuery library on the Google web site) so I moved it to an attachment.
This jQuery code first assigns some code to the click event of each checkbox. It then wraps "this" (the checkbox) in a jQuery matched set and then use parent().parent() to traverse up from the checkbox through the table cell (td) to the table row (tr).
On the row, it finds all checkboxes and disables them using attr which enables you to set an attribute value on an element. At the item, the clicked checkbox is selected.
This code only fires if the checkbox has just been turned on. Otherwise (e.g. without the if check) you wouldn't be able to unckeck both items anymore (which may be what you want though).
This code assumes the same table structure as in my sample HTML so you may need to modify it a bit to match your HTML.
Cheers,
Imar
Last edited by Imar; July 15th, 2011 at 04:09 PM..
|