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

get a table cell value

let's say this is a html table, how can i get the string value contained in
the X cell ?

---------------------
| | | |
---------------------
| | | |
---------------------
| X | | |
---------------------
| | | |
---------------------

thanks
Jul 20 '05 #1
3 73702
"yukatan" <a@a.com> writes:
let's say this is a html table, how can i get the string value contained in
the X cell ?
Don't draw using a proportional font. There is little chance that the
receiver uses the same proportional font. If you draw using a fixed
width font, then at least all other fixed width fonts will give a
correct drawing. My newsreader uses a fixed with font, as does a lot
of others.

---------------------
| | | |
---------------------
| | | |
---------------------
| X | | |
---------------------
| | | |
---------------------


To get the cell, assuming that the id of the table is "tableId":

var table = document.getElementById("tableId");
var row = table.rows[2];
var cell = row.cells[0];

The hard part is getting the content of the cell. If it is plain,
unstyled text, then you can probably use:

var content = cell.firstChild.nodeValue;

Otherwise you must either use proprietary methods like cell.innerText
that doesn't work in all modern browsers, or you must gather the text
recursively. Since you just say "string value", I assume it is plain,
unstyled text.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
In article <ll**********@hotpop.com>, Lasse Reichstein Nielsen <lr*@hotpop.com>
writes:
Otherwise you must either use proprietary methods like cell.innerText
that doesn't work in all modern browsers, or you must gather the text
recursively. Since you just say "string value", I assume it is plain,
unstyled text.


Whether its styled text or not, why not innerHTML if you get out of the W3C and
into proprietary? At least allows it to work somewhere besides IE :(
--
Randy
Jul 20 '05 #3
hi************@aol.com (HikksNotAtHome) writes:
Whether its styled text or not, why not innerHTML if you get out of
the W3C and into proprietary? At least allows it to work somewhere
besides IE :(


Yes, but that doesn't get the text of styled content, but the HTML code.
You will have to remove the tags to get just the text.

It all depends on what the original poster wants, which wasn't clear.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4

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

Similar topics

2
by: Seth | last post by:
How can I hide an entire row of a table if one of the cells in that row is equal to a value drop down box value. My goal is to have a filtered table so that each cell in each row determines if...
2
by: David Bradbury | last post by:
I currently have an iframe on a webpage into which users can insert content. They can further customise the text as I've included buttons such as Bold, Italic, Bullet point etc. This is done along...
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: dschectman | last post by:
This appears to be a feature of IE JavaScript. I am running IE 6.0 with the latest patches from Microsoft. Are there any workarounds other than re-coding the source HTML to place all the...
7
by: slitvinov | last post by:
I am learning Relax NG. The problem is that I cannot figure out how to make a schema for a table. In my case I would like to make a table with any name of child elements (columns) but columns...
6
by: anirban.anirbanju | last post by:
hi there, i've some serious problem to add rows dynamically in a table. my table contains 5 cell. | check | from_value | to_value | color_text | color_value |...
7
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the...
3
by: azegurb | last post by:
hi I have just took from internet dinamic table. this table is dynamic and its rows dynamically can be increased. but i would like how create SUM function that automatically sums each added row...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
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,...

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.