Pi Horse Pi Horse - 1 month ago 8
HTML Question

HTML table td display

I have multiple HTML tables which has some Ruby code embedded in it. It looks like below :

<% loop-1 %>
<table>
<tr>
<td rowspan=" X ">abcd</td>
<td>xyz</td>
</tr>

<% loop-2 %>
<% if (condition) %>
<tr>
<td></td>
<td>xyz1</td>
</tr>
<% end %>
<% end %>
</table>
<% end %>


So as seen above, there are multiple tables generated based on loop-1. Now each table will have atleast one row. After the first row, there is again another loop-2 and some condition. There might be variable number of rows after the first row for each table. I want the first of the first to have the rowspan(X) = no. of total rows for that table.

For example. if after the first row, loop-2 generates 2 more rows, I want the X=3

Answer

You can't do that using only HTML. The only possible way is to count how many occurrence of condition will take place befroe your loop. I.e. executing the same loop earlier and increment X each time condition met.