Op een HTML-pagina staan 2 radiobuttons en 2 div's. Nu wil ik dat div1 zichtbaar wordt (en div2 onzichtbaar) als radiobutton1 (rdo1) gechecked is. Div2 moet zichtbaar worden (en div1 onzichtbaar) als rdo2 is gechecked.
De volgende code heb ik hiervoor geschreven:
De javascript function 'Visible();' werkt echter niet goed. Ongeacht de check wordt altijd de eerste conditie gevolgd
. Wat is er fout?
De volgende code heb ik hiervoor geschreven:
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
| <HTML>
<HEAD>
<title>frmTest2</title>
<script language="javascript">
<!--
function Visible() {
if (document.getElementById('rdo1').value = true) {
document.getElementById('div1').style.visibility = "visible";
document.getElementById('div2').style.visibility = "hidden";
}
else {
if (document.getElementById('rdo2').value = true) {
document.getElementById('div1').style.visibility = "hidden";
document.getElementById('div2').style.visibility = "visible";
}
}
}
-->
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" onload="Visible();">
<form id="Form1" method="post" runat="server">
<INPUT id="rdo1" onclick="Visible();" type="radio" name="radio"
CHECKED>Optie 1
<INPUT id="rdo2" onclick="Visible();" type="radio" name="radio">Optie 2
<DIV id="div1" style="Z-INDEX: 101; LEFT: 24px; WIDTH: 192px;
POSITION: absolute; TOP: 64px; HEIGHT: 64px" ms_positioning="FlowLayout">Div 1
</DIV>
<DIV id="Div2" style="Z-INDEX: 102; LEFT: 24px; WIDTH: 192px;
POSITION: absolute; TOP: 136px; HEIGHT: 64px" ms_positioning="FlowLayout">Div 2
</DIV>
</form>
</body>
</HTML> |
De javascript function 'Visible();' werkt echter niet goed. Ongeacht de check wordt altijd de eerste conditie gevolgd