Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to retrieve Cell information from dynamic HTML table?

Status
Not open for further replies.

Rock6431

Programmer
Mar 23, 2002
56
US
I have a table with CheckBoxes in the left hand column and various information in the other columns in that row. The name property of the CheckBox is dynaically generated, so I can not pull the value of this checkbox as I wouldn't know what name it was assigned when it was generated. I am looking to try to pull the information by looping through the table with something similar to coordinates of (row,col) like in Excel.

Any ideas?
 
Without parsing the HTML using the FSO and string functions there is no way to do this. And the parsing option would be slow and inefficient.

Why are your checkboxes being named dynamically? I've never seen that done before. If you give them all one name but different values then you don't have this problem.
 
I'm unfamiliar with the DOM in various Netscape products (are these documented in any detail?) but for IE later than 3.x this is pretty easy.

The collection tableID.rows returns all of the rows in the table. You navigate this like any other collection in DHTML script.

The collection row.cells will give you access to the cells in the row.

When munching on an individual cell you'll need to pull out the unnamed checkboxes in the elements collection to get their values by using the .children collection of each cell. Identify the child element you want by its tagName value (such as INPUT) and type value (such as CHECKBOX). Be sure to UCase these values to test them, some come back uppercase, others lowercase... in IE 6 for example the case returned matches what was used in the HTML source for the tag.

Browse for details:

 
Thanks ShaneH0 and Dilettante,

I created and named each item dynamically, since I use the name and id's for different actions on a specific record. When these goto some of my other functions, I use this information to locate other field or function specific records or account information without having to go back to the database.

As for the location of the HTML field specific info, I found a quicker method of getting the data and thought I would share. I added another column to my HTML table and am pulling the values from that cell as opposed to the name field of the checkbox. All I have to do now is figure out how to hide that column from appearing on the screen, which I guess, I'll just change the text color to that of the background.

Although it is Jscript, the following is a subFunction to my VBscript which returns the cell value to a hidden text field on my page. I then use that value in my VBscript.

<SCRIPT LANGUAGE=&quot;JScript&quot;>
function GetCell(myROW, myCOL) {
document.all.HIDDENFIELD.value = document.all.TABLENAME.rows(myROW).cells(myCOL).innerText;
}
</SCRIPT>


Thanks again for the help.

Rock6431
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top