I am creating some radio buttons and when I click on one of them some fields appear. My problem is that when I click to the next button the fields from the previous one stay on screen while I need them to disappear. This is the code I have written, I know that the reason of my failure is that it never enters the else statement in my javascript function. Can someone help me, I am a rookie in these two languages, is there a way to keep the previous value sent to the function so that I can compare with it for the else statement? Any other solution would also be well received!
<HTML>
<HEAD> <title> Ticket Choice </title></HEAD>
<BODY>
<FORM>
<SCRIPT type="text/javascript">
function IsCheck(but_Check, if_Check){
if (document.getElementById(but_Check).checked) {
document.getElementById(if_Check).style.display = 'block';
}
else document.getElementById(if_Check).style.display = 'none';
}
</SCRIPT>
<input type = "radio" onclick = "javascript:IsCheck("buttonCheck1","ifChecked1");" name = "plane" id = "buttonCheck1"> PLANE <br>
<div id = "ifChecked1" style="display:none">
<label for = "depart">Departure:</label>
<input type = "text" id = "depart" name = "depart_plane" maxlength = "200"><br>
<label for = "dest">Destination:</label>
<input type = "text" id = "dest" name = "destination_plane" maxlength = "200"><br>
</div>
<input type = "radio" onclick = "javascript:IsCheck("buttonCheck2","ifChecked2");" name = "plane" id = "buttonCheck2"> SHIP <br>
<div id = "ifChecked2" style="display:none">
<label for = "depart">Departure:</label>
<input type = "text" id = "depart" name = "depart_ship" maxlength = "200"><br>
<label for = "dest">Destination:</label>
<input type = "text" id = "dest" name = "destination_ship" maxlength = "200"><br>
</div>
<input type = "radio" onclick = "javascript:IsCheck("buttonCheck3","ifChecked3");" name = "plane" id = "buttonCheck3"> O.S.E <br>
<div id = "ifChecked3" style="display:none">
<label for = "depart">Departure:</label>
<input type = "text" id = "depart" name = "depart_ose" maxlength = "200"><br>
<label for = "dest">Destination:</label>
<input type = "text" id = "dest" name = "destination_ose" maxlength = "200"><br>
</div>
</FORM>
</BODY>
</HTML>