Menu
I am creating a list of areas in town. When the checkbox beside an area is checked, a show/hide layer appears asking if you want: a vertical ad or a horizontal ad (two radio buttons).
Is there a way to clear the radio buttons if the checkbox is unchecked?
<i>
</i><html>
<head>
<script language="JavaScript">
<!--
function doCheck(checkbox){
if(! checkbox.checked){
<i> </i>myForm.theRadios[0].checked=false;
<i> </i>myForm.theRadios[1].checked=false;
<i> </i>// Put your hide layer code here.
} else {
<i> </i>// Put your show layer code here.
}
}
// -->
</script>
<body>
<form name="myForm">
<input type=checkbox onClick="doCheck(this);"> Checkbox <br>
<input type=radio name="theRadios"> Radio Button #1 <br>
<input type=radio name="theRadios"> Radio Button #2
</body>
</html>
Montrose
<!--<input type=button value="Hide Div 1" onClick="show(false,'div1');">-->
</td>
<td valign="top"><div id = "div1" class = "myLayersClass">
<label>
<input type="radio" name="Montrose" value="Montrose_Vertical">
<i>
</i><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
<!-- Begin
// quick browser tests
var ns4 = (document.layers) ? true : false;
var ie4 = (document.all && !document.getElementById) ? true : false;
var ie5 = (document.all && document.getElementById) ? true : false;
var ns6 = (!document.all && document.getElementById) ? true : false;
function show(sw,obj) {
// show/hide the divisions
if (sw && (ie4 || ie5) ) document.all[obj].style.visibility = 'visible';
if (!sw && (ie4 || ie5) ) document.all[obj].style.visibility = 'hidden';
if (sw && ns4) document.layers[obj].visibility = 'visible';
if (!sw && ns4) document.layers[obj].visibility = 'hidden';
}
function check(checkbox,radioButton){
if(! checkbox.checked){
<i> </i>if(radioButton=='Montrose'){
<i> </i> myForm.Montrose[0].checked = false;
<i> </i> myForm.Montrose[1].checked = false;
<i> </i>} else {
<i> </i> myForm.Bellaire.checked = false;
<i> </i>}
}
}
// End -->
</script>
<style type="text/css">
<!--
.myLayersClass {
position: relative;
visibility: hidden;
width: 326px;
height: 19px;
}
-->
</style>
</head>
<body>
<div id="div4" align="left">
<form action="" method="post" name="myForm">
<table width="600" cellspacing="6">
<tr>
<td valign="top"><input name="checkbox" type="checkbox" onClick="show(true,'div1');check(this,'Montrose');" value="Show Div 1">
Montrose
<!--<input type=button value="Hide Div 1" onClick="show(false,'div1');">-->
</td>
<td valign="top"><div id="div1" class="myLayersClass">
<label>
<input type="radio" name="Montrose" value="Montrose_Vertical">
Vertical
&nbsp;&nbsp;&nbsp;<input type="radio" name="Montrose" value="Montrose_Horizontal">
Horizontal&nbsp;</label>
<br>
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input name="checkbox" type="checkbox" id="checkbox" onClick="show(true,'div2');check(this,'Bellaire');" value="Show Div 2">
Bellaire </td>
<td><div id="div2" class="myLayersClass">
<label>
<input type="radio" name="Bellaire" value="Bellaire_Vertical">
Vertical </label>
<br>
</div></td>
<td>&nbsp;</td>
</tr>
</table>
</form>
</div>
</body>
</html>
<i>
</i>function check(checkbox,radioButton){
if(! checkbox.checked){
<i> </i>if(radioButton=='Montrose'){
<i> </i> myForm.Montrose[0].checked = false;
<i> </i> myForm.Montrose[1].checked = false;
<i> </i>} else {
<i> </i> myForm.Bellaire.checked = false;
<i> </i>}
}
}
[CODE]<html>
<head>
<script type="text/javascript">
function toggle(nBox,nDiv,nGroup){
if (nBox.checked)
{document.getElementById(nDiv).style.display = ''}
else {
document.getElementById(nDiv).style.display = 'none';
nRadio = document.getElementsByName(nGroup);
for (i=0; i<nRadio.length; i++)
{nRadio[i].checked = false}
}
}
function init(){
var lastDiv = 3;
for (i=1; i<lastDiv+1; i++)
{document.getElementById('div'+i).style.display = 'none'}
}
onload=init;
</script>
</head>
<body>
<form action="" method="post" name="myForm">
<table width="400" cellspacing="6" cellpadding="5" border="0">
<tbody>
<tr>
<td><input type="checkbox" onclick="toggle(this,'div1','Montrose')">Montrose</td>
<td>
<div id='div1'>
<input type="radio" name="Montrose" value="Montrose_Vertical">Vertical
<input type="radio" name="Montrose" value="Montrose_Horizontal">Horizontal
</div>
</td>
</tr>
<tr>
<td><input type="checkbox" onclick="toggle(this,'div2','Bellaire')">Bellaire</td>
<td>
<div id='div2'>
<input type="radio" name="Bellaire" value="Montrose_Vertical">Vertical
<input type="radio" name="Bellaire" value="Montrose_Horizontal">Horizontal
</div>
</td>
</tr>
<tr>
<td><input type="checkbox" onclick="toggle(this,'div3','Nowhere')">Nowhere</td>
<td>
<div id='div3'>
<input type="radio" name="Nowhere" value="Nowhere_Vertical">Vertical
<input type="radio" name="Nowhere" value="Nowhere_Horizontal">Horizontal
</div>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>[/CODE]
function toggle(nBox,nDiv,nGroup){
if (nBox.checked)
{document.getElementById(nDiv).style.display = ''}
else {
document.getElementById(nDiv).style.display = 'none';
nRadio = document.getElementsByName(nGroup);
for (i=0; i<nRadio.length; i++)
{nRadio[i].checked = false}
}
}
function init(){
var lastDiv = 16;
for (i=1; i<lastDiv+1; i++)
{document.getElementById('div'+i).style.display = 'none'}
}
onload=init;
<input type="radio" name="Cypress" value="Cypress_Horizontal">
Horizontal</span> </div>
[CODE]<html>
<head>
<script type="text/javascript">
function toggle(nBox,nDiv,nGroup){
if (nBox.checked)
{
document.getElementById(nDiv).style.display = '';
document.getElementById(nDiv+'zip').style.display = '';
}
else {
document.getElementById(nDiv).style.display = 'none';
document.getElementById(nDiv+'zip').style.display = 'none';
nRadio = document.getElementsByName(nGroup);
for (i=0; i<nRadio.length; i++)
{nRadio[i].checked = false}}
}
function init(){
var lastDiv = 16;
for (i=1; i<lastDiv+1; i++)
{
document.getElementById('div'+i).style.display = 'none';
document.getElementById('div'+i+'zip').style.display = 'none';
}
}
onload=init;
</script>
</head>
<body>
<form action="" method="post" name="myForm">
<table width="428" cellspacing="2" cellpadding="2" border="0">
<tbody>
<tr>
<td colspan="3"><font color="#cc0033">HOUSTON</font></td>
</tr>
<tr>
<td> </td>
<td>
<input type="checkbox" onclick="toggle(this,'div2','Bellaire')">
<acronym title="Bellaire">Bellaire</acronym>
</td>
<td valign="top">
<div id='div2'>
<span class="zipcodes">
<input type="radio" name="Bellaire" value="Bellaire_Vertical">
Vertical only</span>
</div>
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><span class="zipcodes" id='div2zip'> 77081 | 77401</span></td>
</tr>
<tr>
<td> </td>
<td><input type="checkbox" onclick="toggle(this,'div4','Briargrove')">
<acronym title="Briargrove and Uptown">Briargrove</acronym>
</td>
<td valign="top">
<div id='div4'><span class="zipcodes">
<input type="radio" name="Briargrove" value="Briargrove_Vertical">
Vertical
<input type="radio" name="Briargrove" value="Briargrove_Horizontal">
Horizontal </span></div>
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><span class="zipcodes" id='div4zip'> 77057</span></td>
</tr>
<tr>
<td> </td>
<td><input type="checkbox" onclick="toggle(this,'div5','Downtown')">
<acronym title="Downtown, Midtown and Heights">Downtown</acronym>
</td>
<td valign="top"><div id='div5'><span class="zipcodes">
<input type="radio" name="Downtown" value="Downtown_Vertical">
Vertical
<input type="radio" name="Downtown" value="Downtown_Horizontal">
Horizontal</span> </div></td>
</tr>
<tr>
<td> </td>
<td colspan="2" valign="top"><span class="zipcodes" id='div5zip'> 77002
| 77003 | 77009 | 77010 | 77097</span> </td>
</tr>
<tr>
<td> </td>
<td><input type="checkbox" onclick="toggle(this,'div6','Galleria')">
<acronym title="Galleria, Tanglewood and Uptown">Galleria</acronym> </td>
<td valign="top">
<div id='div6'><span class="zipcodes">
<input type="radio" name="Galleria" value="Galleria_Vertical">
Vertical only</span></div>
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><span class="zipcodes" id='div6zip'> 77056</span></td>
</tr>
<tr>
<td> </td>
<td><input type="checkbox" onclick="toggle(this,'div7','Memorial')">
<acronym title="Addicks, Energy Corridor, Memorial, and West Houston">Memorial</acronym></td>
<td valign="top">
<div id='div7'><span class="zipcodes">
<input type="radio" name="Memorial" value="Memorial_Vertical">
Vertical only</span></div>
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><span class="zipcodes" id='div7zip'> 77077 | 77079</span></td>
</tr>
<tr>
<td width="10"> </td>
<td width="140"><input type="checkbox" onclick="toggle(this,'div1','Montrose')"><acronym title="Boulevard Oaks, Midtown, Montrose, River Oaks and Upper Kirby">Montrose</acronym>
</td>
<td width="258" valign="top">
<div id='div1'><span class="zipcodes">
<input type="radio" name="Montrose" value="Montrose_Vertical">Vertical
<input type="radio" name="Montrose" value="Montrose_Horizontal">Horizontal</span>
</div>
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><span class="zipcodes" id='div1zip' id='div1zip'> 77006 | 77098</span> </td>
</tr>
<tr>
<td> </td>
<td><input type="checkbox" onclick="toggle(this,'div3','RiverOaks')">
<acronym title="Montrose, River Oaks and Upper Kirby">River Oaks</acronym>
</td>
<td valign="top">
<div id='div3'>
<span class="zipcodes"><input type="radio" name="RiverOaks" value="RiverOaks_Vertical">
Vertical only</span></div>
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><span class="zipcodes" id='div3zip'> 77019 | 77098</span></td>
</tr>
<tr>
<td> </td>
<td><input type="checkbox" onclick="toggle(this,'div8','Tanglewood')">
<acronym title="Galleria, Tanglewood and Uptown">Tanglewood</acronym></td>
<td valign="top">
<div id='div8'> <span class="zipcodes">
<input type="radio" name="Tanglewood" value="Tanglewood_Vertical">
Vertical only</span></div>
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><span class="zipcodes" id='div8zip'> 77056</span></td>
</tr>
<tr>
<td> </td>
<td><input type="checkbox" onclick="toggle(this,'div12','EnergyCorridor')">
<acronym title="Energy Corridor, Memorial and West Houston">West Houston</acronym></td>
<td valign="top">
<div id='div12'><span class="zipcodes">
<input type="radio" name="EnergyCorridor" value="EnergyCorridor_Vertical">
Vertical only</span></div>
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><span class="zipcodes" id='div12zip'> 77077</span></td>
</tr>
<tr>
<td> </td>
<td width="140"><input type="checkbox" onclick="toggle(this,'div9','WestU')">
<acronym title="West University Place">West U</acronym></td>
<td width="258" valign="top">
<div id='div9'><span class="zipcodes">
<input type="radio" name="WestU" value="WestU_Vertical">
Vertical
<input type="radio" name="WestU" value="WestU_Horizontal">
Horizontal</span> </div>
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><span class="zipcodes" id='div9zip'> 77006 | 77098</span> </td>
</tr>
<tr>
<td colspan="3"><font color="#cc0033">NORTHWEST</font></td>
</tr>
<tr>
<td> </td>
<td width="140"><input type="checkbox" onclick="toggle(this,'div15','Champions')">
<acronym title="Champions">Champions</acronym></td>
<td width="258" valign="top">
<div id='div15'><span class="zipcodes">
<input type="radio" name="Champions" value="Champions_Horizontal">
Horizontal only</span></div>
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><span class="zipcodes" id='div15zip'> 77069</span> </td>
</tr>
<tr>
<td> </td>
<td width="140"><input type="checkbox" onclick="toggle(this,'div10','Coles')">
<acronym title="Coles Crossing and Cypress">Coles Crossing</acronym></td>
<td width="258" valign="top">
<div id='div10'><span class="zipcodes">
<input type="radio" name="Coles" value="Coles_Vertical">
Vertical
<input type="radio" name="Coles" value="Coles_Horizontal">
Horizontal</span> </div>
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><span class="zipcodes" id='div10zip'> 77429</span> </td>
</tr>
<tr>
<td> </td>
<td width="140"><input type="checkbox" onclick="toggle(this,'div14','Cypress')">
<acronym title="Coles Crossing, Cypress and Fairfield">Cypress</acronym></td>
<td width="258" valign="top">
<div id='div14'><span class="zipcodes">
<input type="radio" name="Cypress" value="Cypress_Vertical">
Vertical
<input type="radio" name="Cypress" value="Cypress_Horizontal">
Horizontal</span> </div>
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><span class="zipcodes" id='div14zip'> 77429 | 77433</span></td>
</tr>
<tr>
<td colspan="3"><font color="#CC0033">WEST/KATY</font></td>
</tr>
<tr>
<td> </td>
<td width="140"><input type="checkbox" onclick="toggle(this,'div11','CincoRanch')">
<acronym title="Cinco Ranch, Grand Lakes and Katy">Cinco Ranch</acronym></td>
<td width="258" valign="top">
<div id='div11'><span class="zipcodes">
<input type="radio" name="CincoRanch" value="CincoRanch_Vertical">
Vertical
<input type="radio" name="CincoRanch" value="CincoRanch_Horizontal">
Horizontal</span> </div>
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><span class="zipcodes" id='div11zip'> 77494</span> </td>
</tr>
<tr>
<td colspan="3"><font color="#CC0033">NORTH/MONTGOMERY</font></td>
</tr>
<tr>
<td> </td>
<td width="140"><input type="checkbox" onclick="toggle(this,'div13','Woodlands')">
<acronym title="Oak Ridge North, Shenandoah and The Woodlands">The Woodlands</acronym></td>
<td width="258" valign="top">
<div id='div13'><span class="zipcodes">
<input type="radio" name="Woodlands" value="Woodlands_Vertical">
Vertical
<input type="radio" name="Woodlands" value="Woodlands_Horizontal">
Horizontal</span> </div>
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><span class="zipcodes" id='div13zip'> 77380 | 77381 | 77382</span> </td>
</tr>
<tr>
<td colspan="3">SW/FORT BEND</td>
</tr>
<tr>
<td> </td>
<td width="140"><input type="checkbox" onclick="toggle(this,'div16','Sugarland')">
<acronym title="First Colony, Greatwood and Sugar Land">Sugar Land</acronym></td>
<td width="258" valign="top">
<div id='div16'><span class="zipcodes">
<input type="radio" name="Sugarland" value="Sugarland_Horizontal">
Horizontal only</span></div>
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><span class="zipcodes" id='div16zip'> 77380 | 77381 | 77382</span> </td>
</tr>
</tbody>
</table>
</form>
</body>
</html>[/CODE]
[CODE]Code tags when posting script.[/CODE]
0.1.9 — BETA 5.18