Ik zit vast met een javascript wat maar niet lijkt te werken.
Doel: table row laten zien/niet laten zien afhankelijk van een radiobutton keuze
Probleem: hij gedraagt zich totaal niet in Firefox
Script:
function switchid(id){
hideallids();
showdiv(id);
}
function hideallids(){
//loop through the array and hide each element by id
for (var i=0;i<ids.length;i++){
hidediv(ids[i]);
}
}
function showallids(){
//loop through the array and hide each element by id
for (var i=0;i<ids.length;i++){
showdiv(ids[i]);
}
}
function hidediv(id) {
//safe function to hide an element with a specified id
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = 'none';
}
else {
if (document.layers) { // Netscape 4
document.id.display = 'none';
}
else { // IE 4
document.all.id.style.display = 'none';
}
}
}
function showdiv(id) {
//safe function to show an element with a specified id
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = '';
}
else {
if (document.layers) { // Netscape 4
document.id.display = '';
}
else { // IE 4
document.all.id.style.display = '';
}
}
}
HTML script:
<script language="JavaScript" type="text/javascript">
var ids=new Array('zichtbaar0', 'zichtbaar1', 'zichtbaar2');
</script>
<tr id="zichtbaar0" style="display:block">
<td>test</td>
</tr>
javascript:hideallids();
javascript:showdiv('zichtbaar0');
474 views