Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I used this javascript function once to join/combine all rows, vertically adjacent, with the same value:</p> <pre><code>&lt;script&gt; function joinRows() { var table = document.getElementById("myTable"); for (var i = table.rows.length-1; i&gt;=0; i--) { row = table.rows[i]; for (var j = row.cells.length-1; j&gt;=0 ; j--) { col = row.cells[j]; if(col.innerHTML==table.rows[i-1].cells[j].innerHTML) { var addRows = table.rows[i].cells[j].rowSpan; table.rows[i].deleteCell(j); table.rows[i-1].cells[j].rowSpan = table.rows[i-1].cells[j].rowSpan + addRows; } } } } &lt;/script&gt; </code></pre> <p>The html code below to test it:</p> <pre><code>&lt;table id="myTable" border="1"&gt; &lt;tr&gt; &lt;td id="td.1.1"&gt;1.1&lt;/td&gt; &lt;td id="td.1.2"&gt;2.2&lt;/td&gt; &lt;td id="td.1.3"&gt;1.3&lt;/td&gt; &lt;td id="td.1.3"&gt;1.4&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="td.2.1"&gt;1.1&lt;/td&gt; &lt;td id="td.2.2"&gt;2.2&lt;/td&gt; &lt;td id="td.2.3"&gt;2.3&lt;/td&gt; &lt;td id="td.1.3"&gt;2.4&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="td.2.1"&gt;1.1&lt;/td&gt; &lt;td id="td.2.2"&gt;3.2&lt;/td&gt; &lt;td id="td.2.3"&gt;2.3&lt;/td&gt; &lt;td id="td.2.3"&gt;3.4&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="td.2.1"&gt;4.1&lt;/td&gt; &lt;td id="td.2.2"&gt;4.2&lt;/td&gt; &lt;td id="td.2.3"&gt;4.3&lt;/td&gt; &lt;td id="td.2.3"&gt;4.4&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;script&gt; //joinRows(); &lt;/script&gt; &lt;br&gt; &lt;button type="button" onclick="joinRows()"&gt;join cells&lt;/button&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload