473,324 Members | 2,356 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.

Logic doesn't recognize table cell value

1
Hello All,

I have a simple data-table being sourced from an Oracle DB. There is a column whereas each cell contains only one character - "R","Y", or "N".

The logic is focused on the correct column because I used the "alert(cell[14].innerText); to see my returned values in the browser.

The issue is when I try to apply a color change on the row background color based on the cell value of either R,Y or N nothing happens...? Here is my code so far, any help would be much appreciated.

Expand|Select|Wrap|Line Numbers
  1.  
  2.         var rows = document.getElementById("trans_separate").getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  3.         //alert(rows.length);
  4.  
  5.         for (i = 0; i < rows.length; i++) {
  6.             cells = rows[i].getElementsByTagName('td');
  7.  
  8.           if (cells[14].textContent === 'R') rows[i].className = "red";
  9.           else if (cells[14].textContent === 'Y') rows[i].className = "yellow";
  10.           else if (cells[14].textContent === 'N') rows[i].className = "green";  
  11.         }  
Mar 20 '13 #1
3 1470
Rabbit
12,516 Expert Mod 8TB
I would use == and not ===. Also, if innerText works, then I would use that instead of textContent.
Mar 20 '13 #2
Dormilich
8,658 Expert Mod 8TB
note: innerText is IE only, textContent is supported from all others and IE 9+.
Mar 20 '13 #3
Rabbit
12,516 Expert Mod 8TB
You should also be aware that textContent and innerText do not always return the same thing.
Mar 21 '13 #4

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

Similar topics

3
by: yukatan | last post by:
let's say this is a html table, how can i get the string value contained in the X cell ? --------------------- | | | | --------------------- | | | ...
1
by: Kai Grossjohann | last post by:
I have a table which contains a top-aligned table cell: .... <tr style="height:40"> ... <td colspan="1" rowspan="2" align="left" valign="top" style="overflow:hidden;">...
0
by: joeZ | last post by:
hi there! I'm just going crazy with this stuff I want to do I though was simple. I just want to locate an image (which is linkeable) below the bottom of a cell. I mean, if the cell is at...
2
by: Sugapablo | last post by:
Can anyone help me out with some code to change three table cells (<td>) when one is hovered over? I have a calendar grid where each day is made up of three table cells and I want all three to...
6
by: Anon | last post by:
I have a table with a cell. The cell's ID is created using a unique name that is held in m_UniqueCellName and the cell is created like so... document.write( "<TD ID="' + m_UniqueCellName +...
1
by: Thanks | last post by:
I have a routine that is called on Page_Init. It retrieves folder records from a database which I display as Link Buttons in a table cell. I set the table cell's bgcolor to a default color (say...
2
by: charles-brewster | last post by:
I'm trying to write a simple JavaScript function which will use a button to copy table cell data into a form input text box as the "value" attribute. The following is intended to test the...
2
by: kudryk | last post by:
Is it possible through javascript to determine the width of a rendered table cell? I have two adjacent tables, one on top of the other. Both tables have the same number of columns, because the...
1
by: Bart Lateur | last post by:
I'm trying to put a utton at the bottom (right) of a TD cell, irrespective of what else is in there. Usually, with other HTML block elements, we're told to use position: relative on the...
5
by: prawasini | last post by:
hi, I have a code where a value in one of a table cell needs to be populated on a command button click event. Scenario: There is a main window having multiple <DIV>s In one of the Div there is a...
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...
1
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: 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: 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: 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: 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...

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.