473,323 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Scrollable Table select row

101 100+
I have the following scrollable table I have to implemet a functionality that I can select a row in it & display that data in popup window..

Any hints/example or similar available implementation?



Expand|Select|Wrap|Line Numbers
  1. http://www.imaputz.com/cssStuff/bigFourVersion.html#
Help
Oct 17 '07 #1
7 6142
acoder
16,027 Expert Mod 8TB
You could pass a reference of the table row to the function which handles the onclick event and use cells[] to retrieve the td values.
Oct 17 '07 #2
buntyindia
101 100+
HI Mod, Thanks for reply but can you please provide a little example how can i do this ...how can I select a row and gets it value......
Oct 17 '07 #3
acoder
16,027 Expert Mod 8TB
Pass the id of the table row (assuming you have given ids to each row to the function:
Expand|Select|Wrap|Line Numbers
  1. onclick="doSomething('tr_id');"
then use the table row's cells array to get the data from the table data cells. If you don't want to do this inline, see the advanced event handling in this article.
Oct 18 '07 #4
buntyindia
101 100+
Hi,

I have made a script that select Row of a HTML table ...
but problem is it is only working with th IE.... what I have to do to make it compatible with the Mozila Firefox..


Please help....

Expand|Select|Wrap|Line Numbers
  1. function mouse_event_handler(e) {
  2.     e = e ||  window.event;
  3.     var cell = e.srcElement || e.target;
  4.     var tname = (cell.nodeType == 1) ? cell.tagName.toLowerCase() : '';
  5.     while(tname != "table" && tname !="td" && tname != "th"){
  6.             cell= cell.parentNode || cell.parentElement;
  7.             tname = cell.tagName.toLowerCase();
  8.     }
  9.     if (tname == "td" || tname == "th") {
  10.         var newClass;
  11.         var cellIdx = _getCellIndex(cell);
  12.         var row = cell.parentNode || cell.parentElement;
  13.         var rowIdx = _getRowIndex(row);
  14.         if (cellIdx == 0 && rowIdx == 0) {
  15.             clearHighlight();
  16.         }
  17.         else if (cellIdx == 0) {
  18.             _setRow();
  19.         }
  20.         else {
  21.             _setRow();
  22.  
  23.         }
  24.     }
  25.     function _getTable() {
  26.         var tbleObj;
  27.         if (mouse_event_handler.previous.table)
  28.             return;
  29.         else {
  30.             tbleObj = row.parentNode || row.parentElement; //tbody
  31.             var tn = tbleObj.tagName.toLowerCase();
  32.             while (tn != "table" && tn != "html") {
  33.                 tbleObj = tbleObj.parentNode || tbleObj.parentElement;
  34.                 tn = tbleObj.tagName.toLowerCase();
  35.             }
  36.             mouse_event_handler.previous.table = tbleObj;
  37.         }
  38.     }//eof _getTable
  39.     function _clearHighlight() {
  40.         _clearRow();
  41.         mouse_event_handler.previous.row = null;
  42.         mouse_event_handler.previous.cellIdx = null;
  43.     }//eof clearHighlight
  44.     function _clearRow() {
  45.         if (mouse_event_handler.previous.row) {
  46.             mouse_event_handler.previous.row.className = "";
  47.             mouse_event_handler.previous.row.cells[0].className = "";
  48.         }
  49.     }//eof clearRow
  50.     function _setRow() {
  51.         _clearRow();
  52.         if (tname == 'td' || mouse_event_handler.previous.row != row) {
  53.             row.className = 'hlt';
  54.             row.cells[0].className = 'hlt';
  55.             mouse_event_handler.previous.row = row;
  56.  
  57.         }
  58.         else {
  59.             mouse_event_handler.previous.row = null;
  60.         }
  61.     }//eof setRow
  62.     function _getCellIndex(cell) {
  63.         var rtrn = cell.cellIndex || 0;
  64.  
  65.         if (rtrn == 0) {
  66.             do{
  67.                 if (cell.nodeType == 1) rtrn++;
  68.                 cell = cell.previousSibling;
  69.             } while (cell);
  70.             --rtrn;
  71.         }
  72.         return rtrn;
  73.     }//eof getCellIndex
  74.     function _getRowIndex(row) {
  75.         var rtrn = row.rowIndex || 0;
  76.  
  77.         if (rtrn == 0) {
  78.             do{
  79.                 if (row.nodeType == 1) rtrn++;
  80.                 row = row.previousSibling;
  81.             } while (row);
  82.             --rtrn;
  83.         }
  84.         return rtrn;
  85.     }//eof getRowIndex
  86. }//eof mouse_event
  87. mouse_event_handler.previous = {cellIdx: null, row: null, table: null};
  88. function addEvent(obj, event_name, fnc) {
  89.  
  90.     if (typeof obj == "undefined")
  91.         return;
  92.     else if (obj.attachEvent)
  93.         obj.attachEvent("on"+event_name, fnc);
  94.     else if (obj.addEventListener && !browser.isKHTML)
  95.         obj.addEventListener(event_name, fnc, false);
  96.     else
  97.         obj["on" + event_name] = fnc;
  98.  
  99. }//eof addEvent
  100.  


Regards,
BuntyIndia
Oct 27 '07 #5
acoder
16,027 Expert Mod 8TB
So what happens? Do you get any errors?
Oct 29 '07 #6
buntyindia
101 100+
So what happens? Do you get any errors?
In Mozilla now it is working fine but in IE some time it give error in line 88

mouse_event_handler.previous.row.cells.0 is null or not a object

Pleaes suggest what i do?
Nov 12 '07 #7
acoder
16,027 Expert Mod 8TB
Does this occur in _clearRow()?
Nov 12 '07 #8

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

Similar topics

1
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...
7
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 |...
2
by: Adi | last post by:
Hi, I made a TBODY scrollable but I have a problem, If there is a "Select" boxes in the table it puts the select boxes on top of the Table head when scrolling. Any idea if that can be fixed?...
25
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...
1
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...
1
by: Keimo Repo | last post by:
Hello I would need some advice, even just speculations... A customer of ours insists on a couple of customer specific design features for our existing multi-customer web application: - A...
6
by: abctech | last post by:
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...
1
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.