I am just wanting to have a div display if a radio box is selected. It's seems simple and most tutes online are for two options, where in my instance I have three.
The logic on this has just been lost on me. Any help would be greatly appreciated.
<!-- // Javascript // -->
<script language="JavaScript" type="text/javascript">
function showhidediv(rad){
var rads=document.getElementsByName(rad.name);
document.getElementById('one').style.display=(rads[1].checked)?'block':'none' ;
document.getElementById('two').style.display=(rads[2].checked)?'block':'none' ;
document.getElementById('three').style.display=(rads[3].checked)?'block':'none' ;
}
</script>
<form name="create" id="create" method="post" enctype="multipart/form-data">
<input name="pagetype" type="radio" value="1" onclick="showhidediv(this);"/>One <br />
<input name="pagetype" type="radio" value="2" onclick="showhidediv(this);"/>two<br>
<input name="pagetype" type="radio" value="3" onclick="showhidediv(this);"/>three<br>
<div id="one" class="CF" style="display:none;" >One </div>
<div id="two" style="display:none;" class="CF" >Two</div>
<div id="three" style="display:none;" class="CF" >Three</div>
</form>
Radio button index start with 0.
Modify:
Use this .. The thing i modified is