troubleshooting Question

Header is fixed on top in a scrollable table

Avatar of CandyKiss
CandyKiss asked on
Web Languages and Standards
8 Comments1 Solution210 ViewsLast Modified:
Hi, does anyone know how to fix the header at the top of a scrollable table?? I mean when u scroll the table, the header will always remain static on top??
---------------------------------------------------------
<DIV ID = "resultTable" STYLE = "TOP: '110'; LEFT: '20'; POSITION:Absolute">
<DIV STYLE = "overflow: scroll; width: 805px; height: 350; border-left: 1px gray solid; border-bottom: 1px gray solid; padding:0px; margin: 0px">
      <TABLE CLASS = "search" WIDTH = "100%">
            <TR CLASS = "dlbl">  /****This is the header portion****/
                  <TD WIDTH = "15%" CLASS = "slbl"><DIV ALIGN = 'CENTER'>IP Address</DIV></TD>
                  <TD WIDTH = "12%" CLASS = "slbl"><DIV ALIGN = 'CENTER'>Host Name</DIV></TD>
                  <TD WIDTH = "5%" CLASS = "slbl"><DIV ALIGN = 'CENTER'>No. of CPU</DIV></TD>            
                  <TD WIDTH = "8%" CLASS = "slbl"><DIV ALIGN = 'CENTER'>Capacity Unit</DIV></TD>            
                  <TD WIDTH = "7%" CLASS = "slbl"><DIV ALIGN = 'CENTER'>No. of MQ Clients</DIV></TD>
                  <TD WIDTH = "7%" CLASS = "slbl"><DIV ALIGN = 'CENTER'>No. of Queue Manager</DIV></TD>
                  <TD WIDTH = "10%" CLASS = "slbl"><DIV ALIGN = 'CENTER'>Type</DIV></TD>
                  <TD WIDTH = "9%" CLASS = "slbl"><DIV ALIGN = 'CENTER'>OS Name (Version)</DIV></TD>
                  <TD WIDTH = "6%" CLASS = "slbl"><DIV ALIGN = 'CENTER'>MQ Series</DIV></TD>
                  <TD WIDTH = "5%" CLASS = "slbl"><DIV ALIGN = 'CENTER'>CSD Applied</DIV></TD>
                  <TD WIDTH = "10%" CLASS = "slbl"><DIV ALIGN = 'CENTER'>Application Name</DIV></TD>
                  <TD WIDTH = "15%" CLASS = "slbl"><DIV ALIGN = 'CENTER'>Group Name</DIV></TD>      
            </TR>

            /****Start of the content portion****/      
            <%
            String opt;
            String txt;
            String str;

            opt = request.getParameter("cboSearch");
            txt = request.getParameter("txtSearch");

                  if (opt == null)
                  {      
                        str = "SELECT * FROM Host ORDER BY App_ID";            
                     }
                  else
                  {
                        if (opt.equals("Cost_Center"))
                        {
                              str = "SELECT DISTINCT * FROM Host WHERE App_ID IN "
                              + "(SELECT App_ID FROM Application WHERE " + opt + " LIKE '%" + txt
                              + "' OR " + opt + " LIKE '" + txt + "%' OR " 
                              + opt + " LIKE '%" + txt + "%') ORDER BY App_ID";
                        }
                        else
                        {
                              if (opt.equals("All"))
                              {
                                    str = "SELECT * FROM Host ORDER BY App_ID";
                                    //rs = stmt.executeQuery (str);            
                              }
                              else
                              {
                                    str = "SELECT * FROM Host WHERE " + opt + " LIKE '%" + txt                                     + "' OR " + opt + " LIKE '" + txt + "%' OR " + opt
                                    + " LIKE '%" + txt + "%' ORDER BY App_ID";
                                    //rs = stmt.executeQuery (str);                        
                              }
                        }
                  }
                  int cnt;
                  cnt = 0;
                  String rowCol;
                  rs = stmt.executeQuery (str);
                  while(rs.next())
                  {
                        cnt++;
                        if ((cnt % 2) == 1)
                        {
                              rowCol = "olbl";
                        }
                        else
                        {
                              rowCol = "elbl";
                        }

                        //Setup the statement for Passing values to another page
                        //String temp = rs.getString("Host_ID");
                        //String ipStr = "ModifyHost.jsp?Reports=" + temp;
                        //String delStr;
            
                           out.println("<TR CLASS = '" + rowCol + "'>");
                        out.println("<TD CLASS = 'rlbl' WIDTH = '15%'><DIV ALIGN = 'CENTER'>" +
                        rs.getString("IP_Address") + "</DIV></TD>");
                           out.println("<TD CLASS = 'rlbl' WIDTH = '13%'><DIV ALIGN = 'CENTER'>" +
                        rs.getString("Name") + "</DIV></TD>");
                        out.println("<TD CLASS = 'rlbl' WIDTH = '5%'><DIV ALIGN = 'CENTER'>" +
                        rs.getString("Num_CPU") + "</DIV></TD>");
                        out.println("<TD CLASS = 'rlbl' WIDTH = '8%'><DIV ALIGN = 'CENTER'>" +
                        rs.getString("Cap_Unit") + "</DIV></TD>");
                        out.println("<TD CLASS = 'rlbl' WIDTH = '7%'><DIV ALIGN = 'CENTER'>" +
                        rs.getString("Num_Client") + "</DIV></TD>");
                        out.println("<TD CLASS = 'rlbl' WIDTH = '8%'><DIV ALIGN = 'CENTER'>" +                         rs.getString("Num_Queue_Manager") + "</DIV></TD>");
                        out.println("<TD CLASS = 'rlbl' WIDTH = '9%'><DIV ALIGN = 'CENTER'>" +
                        rs.getString("Department") + "</DIV></TD>");
                        
                        String a = rs.getString("App_ID");
                        String b = rs.getString("Grp_Name");
                        String c = rs.getString("MQ_Applied_CSD");
                        String d = rs.getString("OS_Name");
                        String e = rs.getString("MQ_Ver");
                        
                        Statement os1_stmt = conn.createStatement();                      
                        String os1 = "SELECT * FROM OS WHERE OS_ID = '" + d + "' ORDER BY Name";
                        ResultSet os1_rs = os1_stmt.executeQuery(os1);

                        if(os1_rs.next())
                        {
                              out.println("<TD CLASS = 'rlbl' WIDTH = '9%'><DIV ALIGN = 'CENTER'>" +
                              os1_rs.getString("Name") + " " + os1_rs.getString("Version") + "</DIV></TD>");
                        }
                        os1_rs.close();
                        os1_stmt.close();
                        os1_rs = null;
                        os1_stmt = null;

                        out.println("<TD CLASS = 'rlbl' WIDTH = '6%'><DIV ALIGN = 'CENTER'>" +
                        e + "</DIV></TD>");

                        Statement csd_stmt = conn.createStatement();                      
                        String csd = "SELECT * FROM CSD WHERE CSD_ID = '" + c + "' ORDER BY Name";
                        ResultSet csd_rs = csd_stmt.executeQuery(csd);

                        if(csd_rs.next())
                        {
                              out.println("<TD CLASS = 'rlbl' WIDTH = '6%'><DIV ALIGN = 'CENTER'>" +                               csd_rs.getString("Name") + "</DIV></TD>");
                        }

                        csd_rs.close();
                        csd_stmt.close();
                        csd_rs = null;
                        csd_stmt = null;

                        Statement app_stmt = conn.createStatement();                      
                        String app = "SELECT * FROM Application WHERE App_ID = '" + a + "' ORDER BY Name";
                        ResultSet app_rs = app_stmt.executeQuery(app);

                        if(app_rs.next())
                        {
                              out.print("<TD CLASS = 'rlbl' WIDTH = '10%'><DIV ALIGN = 'CENTER'>" +                               app_rs.getString("Name") + "</DIV></TD>");
                        }
                        app_rs.close();
                        app_stmt.close();
                        app_rs = null;
                        app_stmt = null;
                        
                        Statement grp_stmt = conn.createStatement();                      
                        String grp ="SELECT * FROM Grp WHERE Grp_ID = '" + b + "' ORDER BY Name";
                        ResultSet grp_rs = grp_stmt.executeQuery(grp);
                        if(grp_rs.next())
                        {
                              out.print("<TD CLASS = 'rlbl' WIDTH = '10%'><DIV ALIGN = 'CENTER'>" +                               grp_rs.getString("Name") + "</DIV></TD>");
                        }
                        out.println("</TR>");

                        grp_rs.close();
                        grp_stmt.close();
                        grp_rs = null;
                        grp_stmt = null;
                  }                              
            }
               finally
               {
                  if(conn != null)
                  {
                     try
                     {
                        conn.close();
                     }
                     catch (Exception ignored) {}
                  }
               }
            %>
</TABLE>
</DIV>
</DIV>
ASKER CERTIFIED SOLUTION
Alopederii

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros