justinbriggs1 Posted September 22, 2008 Share Posted September 22, 2008 Thanks everybody for their help over the past couple of days, but I have another question.I would like to be able to read the contents of a particular cell into a variable. Here is a portion of the code,var tbl = document.getElementById('tblSample');//I need to retrieve the contents of cell 0 in row 2var retrieveRow = tbl.rows[2];var retrieveCell = retrieveRow.cells[0];var cellText = retrieveCell.firstChild.nodeValue;//This is the problem I think//Then I just want to print it for confirmationdocument.write(cellText);Any help would be greatly appreciated.JW Link to comment Share on other sites More sharing options...
jeffman Posted September 22, 2008 Share Posted September 22, 2008 Try this:var cellText = retrieveCell.innerHTML;The following is probably reliable these days and ensures you won't get any HTML tags:var cellText = retrieveCell.innerText || retrieveCell.textContent; Link to comment Share on other sites More sharing options...
justinbriggs1 Posted September 22, 2008 Author Share Posted September 22, 2008 Try this:var cellText = retrieveCell.innerHTML;The following is probably reliable these days and ensures you won't get any HTML tags:var cellText = retrieveCell.innerText || retrieveCell.textContent; Hey thanks that did work Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.