Hey,
ik heb een vraagje aan jullie, ik probeer een table te maken waarvan rijen zijn te selecteren en weer te deselecteren, de geselecteerden krijgen een andere kleur uiteraard (net zo als in phpmyadmin) echter, ik kom er niet uit.
dit is het javascript dat ik gebruik:
nu wordt ie wel de color zeg maar, maar niet weer terug, wat doe ik fout? Dit is de volledige code incl html:
ik heb een vraagje aan jullie, ik probeer een table te maken waarvan rijen zijn te selecteren en weer te deselecteren, de geselecteerden krijgen een andere kleur uiteraard (net zo als in phpmyadmin) echter, ik kom er niet uit.
dit is het javascript dat ik gebruik:
code:
1
2
3
4
5
6
7
8
9
10
11
12
| function change(rowID,color,oldcolor)
{
theRow = document.getElementById(rowID);
currentColor = theRow.style.background;
if(currentColor != color)
{
newColor = color;
} else {
newColor = oldcolor;
}
theRow.style.background = newColor;
} |
nu wordt ie wel de color zeg maar, maar niet weer terug, wat doe ik fout? Dit is de volledige code incl html:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
| <script language="javascript">
function change(rowID,color,oldcolor)
{
theRow = document.getElementById(rowID);
currentColor = theRow.style.background;
if(currentColor != color)
{
newColor = color;
} else {
newColor = oldcolor;
}
theRow.style.background = newColor;
}
</script>
<table width="100%" border="0" class="image" cellpadding="0" cellspacing="0">
<tr class="gradient_header">
<td width="39%">Gebruikersnaam:</td>
<td width="34%">Laatste Login: </td>
</tr>
<tr bgcolor="#FFFFFF" onClick="change('0','#D9EAF2','#FFFFFF');" id="0">
<td>a.devreede</td>
<td>02-06-2005 21:16</td>
</tr>
<tr bgcolor="#F2F2F2" onClick="change('1','#D9EAF2','#F2F2F2');" id="1">
<td>a.kleef</td>
<td>30-05-2005 00:24</td>
</tr>
<tr bgcolor="#FFFFFF" onClick="change('2','#D9EAF2','#FFFFFF');" id="2">
<td>brinkman</td>
<td>02-06-2005 11:10</td>
</tr>
<tr bgcolor="#F2F2F2" onClick="change('3','#D9EAF2','#F2F2F2');" id="3">
<td>j.w.haveman</td>
<td>02-06-2005 11:21</td>
</tr>
<tr bgcolor="#FFFFFF" onClick="change('4','#D9EAF2','#FFFFFF');" id="4">
<td>m.graber</td>
<td>30-05-2005 10:57</td>
</tr>
<tr bgcolor="#F2F2F2" onClick="change('5','#D9EAF2','#F2F2F2');" id="5">
<td>r.dehaas</td>
<td>02-06-2005 19:04</td>
</tr>
</table> |