473,324 Members | 2,541 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,324 software developers and data experts.

skip over table head values

I have the following function that I found and modified from another post

function setValues(evt, table){
var el;
evt=evt||window.event;
el=evt.target||evt.srcElement;

for(;el&&el!=table;el=el.parentNode)
//if(el.nodeName.toLowerCase()!="th")
// if(el.nodeName.toLowerCase()=="th")
// continue;
if(el.nodeName.toLowerCase()=="tr")
break;

document.ds.server.value = el.cells[0].textContent;
document.ds.drive.value = el.cells[1].textContent;
document.ds.submit();
}

I'm calling it in the onclick event for a Table with id="ds". It works great
by allowing me to click any row in the table and passing the first 2 cells
as hidden input fields, but I can't figure out how to skip the Table heads.
I'm using another script to be able to sort the rows by clicking the table
head row and I don't want this to run when I do that. The commented lines
are the things that I have tried so far and failed.

Any help appreciated.

Matt
Aug 5 '05 #1
3 1600


Roughly:

if(el.nodeName.toLowerCase()!="td") //meaning, if the evented node
is anything but a TD
break;

Danny

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Aug 5 '05 #2
Ivo
"Matt Williamson" wrote

for(;el&&el!=table;el=el.parentNode)
//if(el.nodeName.toLowerCase()!="th")
// if(el.nodeName.toLowerCase()=="th")
// continue;
if(el.nodeName.toLowerCase()=="tr")
break;

Quick and dirty does the trick:
if( el.cells[0].nodeName.toLowerCase()=="th" ) { return; }
document.ds.server.value = el.cells[0].textContent;
document.ds.drive.value = el.cells[1].textContent;
document.ds.submit();
}

I'm calling it in the onclick event for a Table with id="ds". It works
by allowing me to click any row in the table and passing the first 2 cells
as hidden input fields, but I can't figure out how to skip the Tableheads.
I'm using another script to be able to sort the rows by clicking the table
head row and I don't want this to run when I do that.


Another idea to modify the sorting function to stop the event from
propagating:

if( e.stopPropagation ) {
e.stopPropagation();
}else if() {
e.cancelBubble = true;
}

hth
ivo
http://www.yorick.onlyfools.com/


Aug 5 '05 #3
Matt Williamson wrote:
I have the following function that I found and modified from another post

function setValues(evt, table){
var el;
evt=evt||window.event;
el=evt.target||evt.srcElement;

for(;el&&el!=table;el=el.parentNode)
//if(el.nodeName.toLowerCase()!="th")
// if(el.nodeName.toLowerCase()=="th")
// continue;
if(el.nodeName.toLowerCase()=="tr")
break;

document.ds.server.value = el.cells[0].textContent;
document.ds.drive.value = el.cells[1].textContent;
document.ds.submit();
}

I'm calling it in the onclick event for a Table with id="ds". It works great
by allowing me to click any row in the table and passing the first 2 cells
as hidden input fields, but I can't figure out how to skip the Table heads.
I'm using another script to be able to sort the rows by clicking the table
head row and I don't want this to run when I do that. The commented lines
are the things that I have tried so far and failed.

Any help appreciated.


Some suggestions:

1. Attach the onclick to rows but not those with TH cells in them
(rowIndex 0?). You could use an onload function to do it.

2. As go up the node tree to the TR parent, bail out if you encounter
a th element (see below).

3. If the TR parent's rowIndex is 0 (presumably the TH cells are the
first row) then don't do stuff.

Here is a routine that will bail out if a th is encountered:

function setValues(evt, table){
evt = evt || window.event;
var el = evt.target || evt.srcElement;

while ( el.parentNode && 'tr' != el.nodeName.toLowerCase() ) {
if ('th' == el.nodeName.toLowerCase() ) return;
el = el.parentNode;
}
// Do stuff
}

Untested but it should work.

[...]
--
Rob
Aug 5 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bhavin G | last post by:
Hi there , I am pretty new at javascripting and i am having this huge problem. I am using asp.net and C# webapplication. In my asp.net aspx file I have a place holder for taking an html table...
25
by: kie | last post by:
hello, i have a table that creates and deletes rows dynamically using createElement, appendChild, removeChild. when i have added the required amount of rows and input my data, i would like to...
3
by: vanisathish | last post by:
Hi I am running a client side javascript timer to periodically refresh the contents of some tables in the HTML page. The table values are dynmically binded from XML DOM object using the <XML tag...
59
by: AK | last post by:
I tried to google "skip scan DB2" but came up with nothing. Does DB2 have the feature under a different name?
24
by: Robin Cole | last post by:
I'd like a code review if anyone has the time. The code implements a basic skip list library for generic use. I use the following header for debug macros: /* public.h - Public declarations and...
1
by: bigmaddaz | last post by:
Ok im designing an application for working out compount interest. The user starts the page, 3 prompts appear, one asking for money invested, next asking for rate of interest, and last one asking for...
5
by: Nirmala123 | last post by:
hi... I want to sort the table using combobox values. I give the code here. address.html: <html> <head> <title>Add a new entry</title> </head>
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...
13
by: ramprakashjava | last post by:
hi, i hav "java.lang.NullPointerException" error while Deleting table records using checkbox in jsp here i enclosed files help quickly plzzz.. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.