473,396 Members | 1,804 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,396 software developers and data experts.

Get Table Cell value using Javascript

How do I get the text from my cell e..g. <td>Test Text</td>

var elTableCells = elTableRow.getElementsByTagName("td");

alert(elTableCells[0].innerText);

Apr 23 '07 #1
4 11168
You answered your own question. What you're doing below should work, as
long as elTableRow is defined prior to that call. Sample:

<html><body>
<script type="text/javascript">
function test() {
var elTableRow = document.getElementById("somerow");
var elTableCells = elTableRow.getElementsByTagName("td");
alert(elTableCells[0].innerText);
}
</script>
<button onclick="test()">click me</button>
<table>
<tr id="somerow">
<td>cell 1</td>
<td>cell 2</td>
</tr>
</table>
</body>
</html>


"C" <C@discussions.microsoft.comwrote in message
news:A8**********************************@microsof t.com...
How do I get the text from my cell e..g. <td>Test Text</td>

var elTableCells = elTableRow.getElementsByTagName("td");

alert(elTableCells[0].innerText);
Apr 23 '07 #2
Hi,
Try this code:
<td id ="tdname">Test Text</td>
alert(document.forms[0].getElementsByTagId("tdname").innerText);
you need to take care of case-sensitivity as javascript is
case-sensitive(that i have not taken care in above code)
Hope this helps
--
If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"C" wrote:
How do I get the text from my cell e..g. <td>Test Text</td>

var elTableCells = elTableRow.getElementsByTagName("td");

alert(elTableCells[0].innerText);
Apr 23 '07 #3
If the cell is a dropdown list, how can I get the selectedIndex value by this approach?
Thank you very much!

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
Apr 30 '07 #4
If the cell is a dropdown list, how can I get the selectedIndex value by this approach?
Thank you very much!

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
Apr 30 '07 #5

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

Similar topics

0
by: yurps | last post by:
Hello here is my html, if you click the missing image in the first column on the left, the div is shown, when clicked again the div disappears...but the bottom border disappears as well...Is there...
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...
1
by: anonieko | last post by:
This example applies to javascript, table, cells, rows > > How do you access rows and columns of a HTML table? > > > <script language="javascript"> alert('start');
1
by: cotton_gear | last post by:
Hello, Fiest of all let me thank this group for so quick in responding to any postings. I am using a javascript based utility from a site to sort the columns of the table. But, for some strange...
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...
2
by: Muzzy | last post by:
Hi, I've used information on these newsgroups to build many pages. So I thought that now that I have my script working (something that I've been working on for about a week), I should post it so...
2
by: philin007 | last post by:
Hi Guys, Could any one help me out with codes to add rows to a table. Well I kinda of got the codes from the following site (http://www.interviewboard.com/DHTMLSamples/DHTMLGridSample.htm) the...
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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:
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...
0
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...
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.