I have the weirdest thing with this code:
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
table {
width: 100%;
border: 1px solid black;
border-collapse: collapse;
}
td {
border: 1px solid black;
}
button {
height: 20px;
display: none;
}
a {
text-decoration: underline;
}
.click-text {
color: darkorange;
}
.click-text:hover {
color: blue;
cursor: pointer;
}
.elucidation-row {
display: none;
}
.score-cell, .uncheck-cell {
width: 100px;
}
</style>
<script>
function showAllItems() {
var elRows = document.getElementsByClassName('elucidation-row');
for (var p=0; p<elRows.length; p++) {
elRows[p].style.display = 'table-row';
}
}
function highlightItem(itemId,buttonId) {
document.getElementById(itemId).style.backgroundColor = 'yellow';
document.getElementById(buttonId).style.display = 'inline';
}
function unCheckRadios(name) {
var radios = document.getElementsByName(name);
for (var n=0; n<radios.length; n++) {
radios[n].checked = false;
}
}
</script>
</head>
<body>
<form action=""><!-- older IEs do weird things with a table with colspan and a form inside -->
<table>
<tbody>
<tr>
<td class="divider-thin" colspan="7"><a class="click-text" id="toggle-all" onclick="showAllItems()">Show all items</a></td>
</tr>
<tr class="elucidation-row section-A" id="A1a-row">
<td class="item-cell">Item</td>
<td class="uncheck-cell"><button id="A1a-button" onclick="unCheckRadios('A1a')">De-check</button></td>
<td class="score-cell"><input type="radio" name="A1a" value="1" onclick="highlightItem('A1a-row','A1a-button')"></td>
<td class="score-cell"><input type="radio" name="A1a" value="2" onclick="highlightItem('A1a-row','A1a-button')"></td>
<td class="score-cell"><input type="radio" name="A1a" value="3" onclick="highlightItem('A1a-row','A1a-button')"></td>
<td class="score-cell"><input type="radio" name="A1a" value="4" onclick="highlightItem('A1a-row','A1a-button')"></td>
<td class="score-cell"><input type="radio" name="A1a" value="5" onclick="highlightItem('A1a-row','A1a-button')"></td>
</tr>
</tbody>
</table>
<p class="elucidation-row">Text line</p>
</form>
</body>
</html>
Open it, click ‘Show all items’, check a radio button, click the appearing ‘De-check’ button, and see that the whole table row is non-displayed again. It looks as if the unCheckRadios function recalls the executed showAllItems function. Why is that, and how do I solve it?