I am a relative newcomer to web programming, so probably I am making some obvious mistake here.
When I am trying to hide a row in a table from javascript, the table layout is getting completely broken. I am using Chrome browser. Originally, the cell content was getting wrapped, and the table width was getting shrunk. I then added style="table-layout: fixed" in the table tag and style="white-space:nowrap" in each td. This stopped the line wrapping, but still the content was not aligned on a line. Cells started moving left if there is space and column width varied from one row to another. I then added a fixed width to each of the <th> and <td> element and also to the div containing the table. Still the problem remained.
The problem can be seen in the following HTML code. If this is run in Chrome and the first column is hidden and shown, the table layout gets broken. The HTML code is not optimal as many different possibilities were tried here to fix the column width and stop word wrapping but none seemed to be working.
Any ideas? Thanks in advance,
<html>
<head>
<title>Table Test</title>
<script language="javascript">
function filterRows() {
var row = document.getElementById('DetailRow1');
var show = document.getElementById('ShowCB');
if (show.checked == false) {
row.style.display = "none";
}
else {
row.style.display = "block";
}
}
</script>
Bookmarks