473,756 Members | 3,499 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to make a scrollable table?

157 New Member
Helo Friends,

I am a novice Java programmer, I'm working with Jsp + Javascript to develop a web application.I only have basic Html knowledge and I mostly use "FrontPage" to develop my web pages but currently my webpage requires some dHtml and CSS fundamentals hence I'm posting a query in this forum expecting some guidance,

I have a floating table in my webpage which I achieved using JS. I have written Jsp code to get database records one by one and append it to this table(i.e basically the table is being created on the fly), its all good till here but now I need to make this table scrollable and thats where I'm stuck! I have attached a snapshot of my webpage here and my code(Jsp) is as below:-

Expand|Select|Wrap|Line Numbers
  1. <%
  2. out.write("<html>\r\n");
  3. out.write("<head>\r\n");
  4. out.write("<style type=text/css>table.T1 {overflow: scroll}</style>");
  5. out.write("<layer id = divStayTopLeft>");
  6. out.write("<div align = right>");
  7. out.write("<table class = T1 align = right border = 1 width=450 cellspacing = 0 cellpadding = 0 >");
  8. out.write("<tr><td bgcolor=#FFFFCC><b>Candidate Name</b></td>");
  9. out.write("<td bgcolor=#FFFFCC><b>Batch-ID</b></td>");
  10. out.write("<td bgcolor=#FFFFCC><b>Reg Amt</b></td>");    
  11. out.write("<td bgcolor=#FFFFCC><b>Total Fees </b></td>");
  12. out.write("<td bgcolor=#FFFFCC><b>Balance</b></td></tr>");    
  13.  
  14. // Here I have the code for getting the backend-table's record and appending it to the Html table as a new row.
  15.  
  16. out.write("</table>");
  17. out.write("</div>");
  18. out.write("</layer>");
  19. out.write("</head>");
  20. out.write("</html>");        
  21. %>
The above code is supposed to make my table scrollable, but it doesn't work, can someone check it for me please and advice me how to go about it? Or if any other approach of carrying this out please suggest!
Jan 27 '07 #1
6 20552
abctech
157 New Member
Here is the snapshot
Jan 27 '07 #2
drhowarddrfine
7,435 Recognized Expert Expert
I have a few minutes right now and I'll work on this. Your code is very, very, very out of date. For example, there is no such thing as a <layer> tag and hasn't been used since 1998, I think.
Jan 27 '07 #3
drhowarddrfine
7,435 Recognized Expert Expert
This is as far as I can go right now. Hope it can get you started.
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2.    "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head><title></title>
  5. <style type=text/css>
  6.     #divStayTopLeft{
  7.         height:100px;
  8.         overflow:scroll
  9.         }
  10.     table.T1 {
  11.         text-align:center;
  12.         font-weight:bold;
  13.         float:right;
  14.         width:450px;
  15.         }
  16.  
  17.     .highlighted {
  18.         background-color:#ffffcc;
  19.         border:1px solid black;
  20.         }
  21.  
  22. </style>
  23. </head>
  24. <body>
  25.  
  26. <div id = "divStayTopLeft">
  27. <div>
  28. <table class = T1 cellspacing = 0 cellpadding = 0 >
  29. <tr><td class="highlighted">Candidate Name</td>
  30. <td class="highlighted">Batch-ID</td>
  31. <td class="highlighted">Reg Amt</td>
  32. <td class="highlighted">Total Fees</td>
  33. <td class="highlighted">Balance</td></tr>
  34. <tr><td>hello</td></tr>
  35. <tr><td>hello</td></tr>
  36. <tr><td>hello</td></tr>
  37. </table>
  38. </div>
  39. </div>
  40.  
  41. </body>
  42. </html>
  43.  
Jan 27 '07 #4
abctech
157 New Member
I have a few minutes right now and I'll work on this. Your code is very, very, very out of date. For example, there is no such thing as a <layer> tag and hasn't been used since 1998, I think.
Helo and thanks a lot for your time and inputs,much appreciated!

To be honest I just have basic Html knowledge and I have never worked with the <div> and <layer> tags before!

this is the script that I've incorporated into my webpage to give my Html-table a floating-effect, and its working fine too but the problem is that now I need the table to be scrollable as well.I tried to apply the CSS -overflow property to this table as one can see in my scriptlet-code..but it doesnt work..not sure if thats even the right way to use 'overflow' !

Presently I'm looking into the code that you have provided here but I still dont know how to place it into my Jsp scriptlet..stil l working on it!
Jan 28 '07 #5
abctech
157 New Member
I made the changes in my page.
Now my table is scrollable but unlike earlier it doesnt float,it just appears at the bottom of the page!

This is how my entire webpage(JSP) looks like now:-

Expand|Select|Wrap|Line Numbers
  1. <%@ page language = "JAVA" import = "java.sql.*"  %>
  2. <html>
  3. <head>
  4. <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
  5. <meta name="ProgId" content="FrontPage.Editor.Document">
  6. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  7. <title></title>
  8. <style type=text/css>
  9.     #divStayTopRight{
  10.         height:100px;
  11.         overflow:scroll
  12.         }
  13.     table.T1 {
  14.         text-align:center;
  15.         font-weight:bold;
  16.         float:right;
  17.         width:450px;
  18.         }
  19.  
  20.     .highlighted {
  21.         background-color:#ffffcc;
  22.         border:1px solid black;
  23.         }    
  24. </style>
  25. <script language = “javascript”>
  26. // some clientside validation code
  27. </script>
  28. </head>
  29. <body>
  30. <form name = “Students”>
  31. <table>
  32. <!—This is the main layout table and I have fixed my entire webpage in to this table -->
  33. </table>
  34. </form>
  35. <%
  36.     PreparedStatement pst ; 
  37.     ResultSet rs = null ;
  38.  try
  39.  {
  40.    pst = con.prepareStatement(“select * from Students”);    
  41.    rs = pst.executeQuery();
  42.  
  43.   if (rs != null)
  44.   {            
  45.       out.write("<div id = divStayTopRight>");
  46.       out.write("<div>");
  47.       out.write("<table class = T1 border = 1 cellspacing=0 cellpadding=2>");
  48.       out.write("<tr>");
  49.       out.write("<th  bgcolor=lightgrey>Candidate Name</th>");
  50.       out.write("<th  bgcolor=lightgrey>Batch-ID</th>");
  51.       out.write("<th  bgcolor=lightgrey>Reg Amt</th>");
  52.       out.write("<th  bgcolor=lightgrey>Total Fees </th>");
  53.       out.write("<th  bgcolor=lightgrey>Balance</th>");
  54.       out.write("</tr>");    
  55.  
  56.       // Here I have the code for getting the backend record and appending it to the Html table
  57.       while(rs.next())
  58.        {                
  59.                out.write("<tr><td >” + rs.getString(1) + "</b></a></td>");
  60.                out.write("<td>" + rs.getString(2) + "</td>");
  61.                out.write("<td>" + rs.getLong(3) + "</td>");
  62.                out.write("<td>" + rs.getLong(4) + "</td>");
  63.                out.write("<td>" + rs.getLong(5)+ "</td></tr>");    
  64.        }        
  65.        out.write("</table>");    
  66.        out.write("</div>");
  67.        out.write("</div>");                
  68.   }
  69.   rs.close();    
  70.   pst.close();
  71.  }
  72.  catch(Exception e)
  73.  {
  74.      e.printStackTrace();
  75.  }    
  76. %>    
  77. </body>
  78. </html>
and this is the script I came across to make a table float on the webpage:-

Expand|Select|Wrap|Line Numbers
  1. <script>
  2. if (!document.layers)
  3. document.write('<div id="divStayTopLeft" style="position:absolute">')
  4. </script>
  5.  
  6. <layer id="divStayTopLeft">
  7.  
  8. <!--EDIT BELOW CODE TO YOUR OWN MENU-->
  9. <table border="1" width="130" cellspacing="0" cellpadding="0">
  10.   <tr>
  11.     <td width="100%" bgcolor="#FFFFCC">
  12.       <p align="center"><b><font size="4">Menu</font></b></td>
  13.   </tr>
  14.   <tr>
  15.     <td width="100%" bgcolor="#FFFFFF">
  16.       <p align="left"> <a href="http://www.dynamicdrive.com">Dynamic Drive</a><br>
  17.        <a href="http://www.dynamicdrive.com/new.htm">What's New</a><br>
  18.        <a href="http://www.dynamicdrive.com/hot.htm">What's Hot</a><br>
  19.        <a href="http://www.dynamicdrive.com/faqs.htm">FAQs</a><br>
  20.        <a href="http://www.dynamicdrive.com/morezone/">More Zone</a></td>
  21.   </tr>
  22. </table>
  23. <!--END OF EDIT-->
  24.  
  25. </layer>
  26.  
  27.  
  28. <script type="text/javascript">
  29.  
  30. /*
  31. Floating Menu script-  Roy Whittle (http://www.javascript-fx.com/)
  32. Script featured on/available at http://www.dynamicdrive.com/
  33. This notice must stay intact for use
  34. */
  35.  
  36. //Enter "frombottom" or "fromtop"
  37. var verticalpos="frombottom"
  38.  
  39. if (!document.layers)
  40. document.write('</div>')
  41.  
  42. function JSFX_FloatTopDiv()
  43. {
  44.     var startX = 3,
  45.     startY = 150;
  46.     var ns = (navigator.appName.indexOf("Netscape") != -1);
  47.     var d = document;
  48.     function ml(id)
  49.     {
  50.         var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
  51.         if(d.layers)el.style=el;
  52.         el.sP=function(x,y){this.style.left=x;this.style.top=y;};
  53.         el.x = startX;
  54.         if (verticalpos=="fromtop")
  55.         el.y = startY;
  56.         else{
  57.         el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
  58.         el.y -= startY;
  59.         }
  60.         return el;
  61.     }
  62.     window.stayTopLeft=function()
  63.     {
  64.         if (verticalpos=="fromtop"){
  65.         var pY = ns ? pageYOffset : document.body.scrollTop;
  66.         ftlObj.y += (pY + startY - ftlObj.y)/8;
  67.         }
  68.         else{
  69.         var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
  70.         ftlObj.y += (pY - startY - ftlObj.y)/8;
  71.         }
  72.         ftlObj.sP(ftlObj.x, ftlObj.y);
  73.         setTimeout("stayTopLeft()", 10);
  74.     }
  75.     ftlObj = ml("divStayTopLeft");
  76.     stayTopLeft();
  77. }
  78. JSFX_FloatTopDiv();
  79. </script>
Now I need to add the above code in my scriptlet to give my table a floating effect! Not sure how to achieve that..Still working on it !
Attached Images
File Type: jpg image007.jpg (13.4 KB, 775 views)
Jan 28 '07 #6
abctech
157 New Member
The issue is resolved now using <iframe> and <div>, the iframe is scrollable as well as floating!
here is the view

Thanks to this forum for all the help!
Jan 29 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
11271
by: Muralidhar | last post by:
Hi, I'm having a jsp page which is having a table and a div tag.The heading such as a radio button,Name , Age etc. are fixed.Only the data under it is scrolling. So i've set one table for header which are fixed. Then a div tag inside which there is a table which is used for scrolling the data.When i select a radio i'm submitting the form.The problem is here i'm able to set focus to the radio button, but i'm unable to maintain the...
7
11653
by: Matt Kruse | last post by:
This is a typical layout, but I have specific requirements. I'm trying to figure out a) if it's possible to meet the requirements and b) if so, how. +---------------+ | header | +---------------+ | body | | (scrollable) | +---------------+ | footer |
25
36366
by: Michael Schuerig | last post by:
I'm trying to do something seemingly very simple, but it's brought me close to crushing my head on the keyboard. All I want is a table where the head row is fixed and the body columns below are scrollable (with the ordinary scrollbars, no less). Whatever I try, the columns in the head and the body aren't aligned; the widths are computed independently which gives a completely ragged look. Michael --
11
24085
by: Matt Kruse | last post by:
This is a common requirement - "freeze panes" in a table, so that some header rows and some columns on the left are frozen while the body content scrolls. This makes large tables more usable on screen. There are a number of solutions available. For example, http://www.litotes.demon.co.uk/example_scripts/tableScroll.html I'm just wondering if anyone knows of a "latest and greatest" script to solve this problem. My requirement at the...
1
3049
by: david.joyce | last post by:
I am aware that v7 Static Scrollable Cursors do not work with pseudo-conversational CICS because of the temp work file being destroyed but will v8 Dynamic Scrollable Cursors work with pseudo-conversational CICS due to these cursors directly using the base table?
1
16974
by: since | last post by:
I figured I would post my solution to the following. Resizable column tables. Search and replace values in a table. (IE only) Scrollable tables. Sortable tables. It is based on a lot examples I found on the web. Works in IE and mozilla. http://www.imaputz.com/cssStuff/bigFourVersion.html
3
2369
by: anniejose | last post by:
I am facing an issue in displaying a calendar popup on click of a calendar icon in one of my JSP pages. In my JSP page I have 3 calendar icons in a horizontally scrollable table. If I click the 1st calendar icon, the calendar gets popped up. Then if I click the 2nd calendar icon, the image gets popped up properly. Now I have to scroll to the right to view the 3rd calendar icon. Now when I click the 3rd calendar icon, the calendar image gets...
5
1992
by: phub11 | last post by:
Hi all, This is a pretty simple question, but after some hunting on the web I can't find the answer: I have a table embedded in a scrollable div, and have each cell anchored so that when a click on a button in another table, the div is scrolled to the corresponding cell of the first table. However, it is positioned such that the cell's contents start at the top-left of the window. Can I add code which centers the contents of the...
0
9273
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10032
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9841
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9711
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.