Ask a Question

How to determine if an HTML table cell contains a textbox?


How to determine if an HTML table cell contains a textbox?


I have the following script that loops through an HTML table and saves out the contents of the cells to a .txt file. I would like to modify this script to ONLY print out to the file if the cell contains a textbox:


for (var i = 0; i < table.rows.length; i++)
			aqFile.WriteToTextFile(fileName, Chr(13) + chr(10) + "Row " + i + Chr(13) + chr(10), aqFile.ctUTF8);
			for (var j = 0; j < table.rows.item(i).cells.length; j++)
      aqFile.WriteToTextFile(fileName, "Cell " + j + ": " + table.rows.item(i).cells.item(j).innerText + Chr(13) + chr(10), aqFile.ctUTF8);


Suggestions would be appreciated. Thanks!

Community Hero



Create an alias for the textbox using wildcards or conditional name mapping, to cover all possible textbox' locations inside the grid. Then use if statement like:


for (i=0; i<rows.lenght; i++) {

    for (j=0; j<cells.lenght; j++) {

        if (rows[i].cells[j].textbox.Exists) {



I suspect the cell can exist, but be empty. That being the case, the above would still write out all cells.


So probably better to extract the cell content, but only write it out if the string length is > 0. Or something along those lines.

Showing results for 
Search instead for 
Did you mean: