473,652 Members | 3,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Scrollable Table select row

101 New Member
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 6159
acoder
16,027 Recognized Expert Moderator MVP
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 New Member
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 Recognized Expert Moderator MVP
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 New Member
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 Recognized Expert Moderator MVP
So what happens? Do you get any errors?
Oct 29 '07 #6
buntyindia
101 New Member
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_han dler.previous.r ow.cells.0 is null or not a object

Pleaes suggest what i do?
Nov 12 '07 #7
acoder
16,027 Recognized Expert Moderator MVP
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
11263
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
11643
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 |
2
2231
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? Thanks
25
36348
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 --
1
3038
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
2782
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 top header with a dropdown menu which does not scroll when the page is scrolled. - A lower detail part of the screen (table) where the headers stay, and
6
20544
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 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...
1
16950
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
0
8367
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8279
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
8703
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8467
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
8589
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...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5619
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();...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.