faqts : Computers : Programming : Languages : JavaScript : Tables

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

9 of 11 people (82%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How to find no of columns in a Table?

Dec 4th, 2003 06:58
Russ Locke, sushil Pan,


1st) assign an id to the table
<table id="countcolumns">
2nd) create your JS function:
function tableColumns() {
  try {
    return document.getElementById("countcolumns").rows[0].cells.length;
  }
  catch(e) { return 0; } // table has no rows - therefore no columns
}