Show/Hide Multiple Rows in Table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Wayne Eveleigh
    New Member
    • Nov 2011
    • 2

    #1

    Show/Hide Multiple Rows in Table

    Hi, I am working on a table with asp and I would like to add a feature to show/hide all rows within the a section of the table. This code show/hide only one row at a time, so I need help with show/hide all related rows within the section.
    Thanks.

    Code:
    function sh_RowShowHide(sh_RowID) {
    var currRow = document.getElementById(sh_RowID);
    if (currRow.style.display=="none") {
    currRow.style.display="";
    document.getElementById(sh_RowID+"img").src = sh_HideImg;
    } else {
    currRow.style.display="none";
    document.getElementById(sh_RowID+"img").src = sh_ShowImg;
    }
    }

    The recordset is determine by a loop within a loop.

    Code:
    <%
    FilterParam = Recordset1.Fields.Item("request_id").Value
    Recordset3.Filter = "related_request = '" & FilterParam & "'" 
    Do while ( not Recordset3.EOF)
    %>
    Last edited by Dormilich; Nov 24 '11, 07:37 AM. Reason: please use [CODE] [/CODE] tags when posting code
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    How do you know they're related? Sample data would go a long way.

    Comment

    • Wayne Eveleigh
      New Member
      • Nov 2011
      • 2

      #3
      Hi, Recordset1 returns all of the request ids to the web page table
      then the user should be able to click on an image to expand the related ids that are assigned with the target group name.

      Code:
      <img
      src="/POW/global/images/arrow_out_new.gif" width="20" height="11" border="0"   id="<%=Recordset1.Fields.Item("request_id")%>img"
      style="clear:both;"
      onclick="toggle('name')" />
      
      function toggle(name) {
      tr=document.getElementsByTagName('tr')
      for (i=0;i<tr.length;i++){
      if (tr[i].getAttribute(name)){
      if (tr[i].style.display=='none'){tr[i].style.display = '';}
      else {tr[i].style.display = 'none';}
      }
      }
         }
      Last edited by Dormilich; Nov 24 '11, 07:42 AM. Reason: please use [CODE] [/CODE] tags when posting code

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Loop through and check each group name. Something along the lines of
        Code:
        tempVar = clicked on group name
        for each row
           if row's group name = tempVar then
              toggle visibility
           end if
        next row

        Comment

        Working...