I have multiple column headers that spans of multiple column and I would like to find the correct header number/count for the columns. Also some of the table data have rowspan and colspan.
I want to be able to click any cell or table data and get its left and top headers.
So if I click the with "D9:LH1-TH4(H4a)" I should get:
- Left Header is: LH1, Top Header1 is TH4 and Top Header 2 is H4a
And if I click the with "D3:LH2-TH2(H2b-H4a)" I should get:
- Left Header is LH2, Top Header 1 is TH2 and Top Header 2 is H2b
Example:
<table width="200" border="1" style="background-color:#000; color:#FFF">
<tr>
<th scope="col"> </th>
<th colspan="2" scope="col"> TH1 </th>
<th colspan="4" scope="col"> TH2 </th>
<th colspan="6" scope="col"> TH4 </th>
</tr>
<tr>
<th scope="col"> </th>
<th scope="col"> H1a </th>
<th scope="col">H1b</th>
<th scope="col"> H2a</th>
<th scope="col">H2b</th>
<th scope="col">H2c</th>
<th scope="col">H2d</th>
<th colspan="6" scope="col"> H4a </th>
</tr>
<tr>
<th rowspan="3" scope="row"><span>LH1</span></th>
<td colspan="2" rowspan="3">D1:LH1-TH1(H1a-H1b)</td>
<td colspan="3" rowspan="2">D2:LH1-TH2(H2a-H2c)</td>
<td rowspan="3">D5:LH1-TH2(H2d)</td>
<td rowspan="3">D6:LH1-TH4(H2a-H2c)</td>
<td colspan="2">D7:LH1-TH4(H4a)</td>
<td>D8:LH1-TH4(H4a)</td>
<td rowspan="3">D13:LH1-TH4(H4a)</td>
<td rowspan="3">D14:LH1-TH4(H4a)</td>
</tr>
<tr>
<td colspan="3">D9:LH1-TH4(H4a)</td>
</tr>
<tr>
<td colspan="2">D3:LH1-TH2(H2a-H2b)</td>
<td>D4:LH1-TH2(H2c)</td>
<td>D10:LH1-TH4(H4a)</td>
<td>D11:LH1-TH4(H4a)</td>
<td>D12:LH11-TH4(H4a)</td>
</tr>
<tr>
<th scope="row"><span>LH2</span></th>
<td colspan="2" >D1:LH2-TH1(H1a-H1b)</td>
<td colspan="3">D2:LH2-TH2(H2a-H2c)</td>
<td colspan="5">D3:LH2-TH2(H2b-H4a)</td>
<td>D4:LH2-TH4(H4a)</td>
<td>D5:LH2-TH4(H4a)</td>
</tr>
</table>