Does anyone know how to show/hide layers based on a radio button selection? For example, I have a Question followed by two radio buttons, Yes and No. If they select Yes, a DIV should appear underneath the Question (this DIV is filled with checkboes). If they select No, nothing happens, or the DIV hides (if is was open). All DIVs should initially be hidden.
I found the following, but it only shows the top row of the DIV. I would also think that the DIV itself should have the ID, not the table or rows.
Any ideas? Below is the code.
Thanks
Dig
---------------------------------------------------------
<html>
<head>
<script type="text/JavaScript" >
<!--
function showlayer(theTable)
{
if (document.getElementById(theTable).style.display == 'none')
{
document.getElementById(theTable).style.display = 'block';
}
}
//-->
<!--
function hidelayer(theTable)
{
if (document.getElementById(theTable).style.display == 'none')
{
document.getElementById(theTable).style.display = 'none';
}
else
{
document.getElementById(theTable).style.display = 'none';
}
}
//-->
</script>
</head>
<body>
<table width="824" border="0" cellpadding="2" cellspacing="0" bordercolor="#DFDFDF" bgcolor="#CCCCCC" >
<tr width="100%">
<td><b>Do you have pets?</b></td>
</tr>
<tr width="100%">
<td>
<input type="radio" name="pctype" value="layer" onFocus="showlayer('layer');return true;"/>
<span class="linkswhite">Yes</span>
<input type="radio" name="pctype" value="desktop" onFocus="hidelayer('layer');return false;"/>
<span class="linkswhite">No</span></td>
</tr>
</table>
<br>
<div class="options">
<table width="825" border="0" cellpadding="0" cellspacing="0">
<tr id="layer" style="display: none;">
<td width="72" class="linkswhite"><input type="checkbox" name="checkbox" value="checkbox">
Yes </td>
<td width="79" class="linkswhite"><input type="checkbox" name="checkbox2" value="checkbox">
No</td>
<td width="674">Are you interested in purchasing dog food? </td>
</tr>
<tr id="layer" style="display: none;">
<td class="linkswhite"><input type="checkbox" name="checkbox" value="checkbox">
Yes </td>
<td class="linkswhite"><input type="checkbox" name="checkbox2" value="checkbox">
No</td>
<td>Are you interested in purchasing cat food? </td>
</tr>
</table>
</div>
</body>
</html>
I found the following, but it only shows the top row of the DIV. I would also think that the DIV itself should have the ID, not the table or rows.
Any ideas? Below is the code.
Thanks
Dig
---------------------------------------------------------
<html>
<head>
<script type="text/JavaScript" >
<!--
function showlayer(theTable)
{
if (document.getElementById(theTable).style.display == 'none')
{
document.getElementById(theTable).style.display = 'block';
}
}
//-->
<!--
function hidelayer(theTable)
{
if (document.getElementById(theTable).style.display == 'none')
{
document.getElementById(theTable).style.display = 'none';
}
else
{
document.getElementById(theTable).style.display = 'none';
}
}
//-->
</script>
</head>
<body>
<table width="824" border="0" cellpadding="2" cellspacing="0" bordercolor="#DFDFDF" bgcolor="#CCCCCC" >
<tr width="100%">
<td><b>Do you have pets?</b></td>
</tr>
<tr width="100%">
<td>
<input type="radio" name="pctype" value="layer" onFocus="showlayer('layer');return true;"/>
<span class="linkswhite">Yes</span>
<input type="radio" name="pctype" value="desktop" onFocus="hidelayer('layer');return false;"/>
<span class="linkswhite">No</span></td>
</tr>
</table>
<br>
<div class="options">
<table width="825" border="0" cellpadding="0" cellspacing="0">
<tr id="layer" style="display: none;">
<td width="72" class="linkswhite"><input type="checkbox" name="checkbox" value="checkbox">
Yes </td>
<td width="79" class="linkswhite"><input type="checkbox" name="checkbox2" value="checkbox">
No</td>
<td width="674">Are you interested in purchasing dog food? </td>
</tr>
<tr id="layer" style="display: none;">
<td class="linkswhite"><input type="checkbox" name="checkbox" value="checkbox">
Yes </td>
<td class="linkswhite"><input type="checkbox" name="checkbox2" value="checkbox">
No</td>
<td>Are you interested in purchasing cat food? </td>
</tr>
</table>
</div>
</body>
</html>