> -----Original Message-----
> From: Karl Swedberg [mailto:[EMAIL PROTECTED] 

> Forgive me if you've already posted it, but would you mind 
> showing us the HTML? Labels can wrap around an input, but 
> they don't have to, so seeing what the relationship is 
> between the label and the input (checkbox) would help tremendously.

Karl - sorry - code would help huh :)

I was thinking about wrapping the label around the input - guess I could
go either way on that one - but here's my current HTML (this is actually
wrapped up in a ColdFusion loop so it outputs a huge list of topics and
categories:

Topic 1
0 item 1
0 item 2

Topic 2...
0 item 1
0 item 2

etc...


HTML
==========================================
<h3 class="right">TOPIC</h3>
<div class="details">
  <div>
        <input type="checkbox" value="#qryTopics.topicid#"
name="topic_#qryTopics.topicid#" id="topic_#qryTopics.topicid#">
        <label class="label"
for="topic_#qryTopics.topicid#">#qryTopics.topic#</label>
  </div>
</div>

jQuery
===========================================
// need to make this a function so we can re-apply row striping after
collapse/expand??
        $('label:odd').removeClass('even').addClass('odd');
        $('label:even').removeClass('odd').addClass('even');

// show all unchecked by default?
        $('h3').click(function() {
        // show details div
                $(this).next().toggle("fast"); 
        // toggle arrow indicator if expanded
                $(this).toggleClass('down').toggleClass('right');  
        // hide unchecked items (need to add some logic to show if none
are checked
        
$(this).next('.details').find('input:checkbox').not(':checked').parent()
.hide();  
         });

This 'sort of' works.  I can check the boxes - click on the H3 and then
when I re-expand the H3 - I only see the checked items.  The problem is
if the user hides a topic without checking anything - I need to add in
some logic - if NONE of them are checked to allow them  to see all the
unchecked items again - that's todays challenge... ;)

Thanks for any insight you can offer!  I learned a lot yesterday just in
trial and error - but I'm always wondering when I do things in jQuery if
it's the 'best' way... :)

Jim

Reply via email to