Forum: Ruby on Rails Collapsible Hide/Show DIV

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
F0b2015753f202632c88be5d0407d110?d=identicon&s=25 ruby noob (Guest)
on 2007-04-21 07:33
Hi there.  I posted this before but wanted to change the subject.  I
want to have a collapsible div inside of a for loop.  I've been messing
around with it and could only get 1 item out of a few to be able to
hide.  I'm just using this:

<script language="javascript">
  function toggleDiv(divid){
    if(document.getElementById(divid).style.display == 'none'){
      document.getElementById(divid).style.display = 'block';
      document.getElementById(divid).style.display = 'none';

Now, I have for example a major category, with many items in that
category.  What I want to do is, show the category name, but under this
category, hide the related items.  This is done is one loop since I have
a HASBTM relationship.  For example then in pseudo code:

for each cat in cateogry  /possible cats are kitchen, living room,
 <td>Kitchen (show more)</td>
   <td>knife $3.00 Buy Now</td>
   <td>Spatula $5.00 Buy Now</td>

I want to do something like this.  Any help would be nice
This topic is locked and can not be replied to.