E
evanburen
I'm passing the name of a div and the name of checkbox to this function
which either hides or displays the div. My problem is this line
// var the_box = window.document.frmCheckboxes.chkCompanyBoard;
I want to assign the name of the checked checkbox to var the_box rather
than just hard-code chkCompanyBoard
function hideLayer2(whichLayer,the_box)
{
var the_box = window.document.frmCheckboxes.chkCompanyBoard;
var the_switch = "";
if (the_box.checked == false) {
document.getElementById(whichLayer).style.display = 'none';
var strshowhide=0;
frmPanelStatus.location.href="panelstatus.asp?showhide=" +
strshowhide + "&whichLayer=" + whichLayer;
} else {
document.getElementById(whichLayer).style.display = 'inline';
var strshowhide=1;
frmPanelStatus.location.href="panelstatus.asp?showhide=" +
strshowhide + "&whichLayer=" + whichLayer;
}
}
<form name="frmCheckboxes">
<table border="0" width="95%" align="center">
<tr>
<td><input type="checkbox" name ="chkCompanyBoard"
onClick="hideLayer2('CompanyBoard',this);">Company and Board
Description</td>
<td><input type="checkbox" name ="chkEvents"
onClick="hideLayer2('Events',this);">Events Reported For This
Company</td>
<td><input type="checkbox" name ="chkAboutBoard"
onClick="hideLayer2('AboutBoard',this);">About the Board</td>
</tr>
<tr>
<td><input type="checkbox" name ="chkCommittees"
onClick="hideLayer2('Committees');">Current Committee Assignments</td>
<td><input type="checkbox" name ="chkTransactions"
onClick="hideLayer2('Transactions');">Related Party Transactions</td>
<td><input type="checkbox" name ="chkConnections"
onClick="hideLayer2('Connections');">Director Connections</td>
</tr>
</table>
</form>
<div id="CompanyBoard">stuff</div>
<div id="Events">stuff</div>
<div id="AboutBoard">stuff</div>
which either hides or displays the div. My problem is this line
// var the_box = window.document.frmCheckboxes.chkCompanyBoard;
I want to assign the name of the checked checkbox to var the_box rather
than just hard-code chkCompanyBoard
function hideLayer2(whichLayer,the_box)
{
var the_box = window.document.frmCheckboxes.chkCompanyBoard;
var the_switch = "";
if (the_box.checked == false) {
document.getElementById(whichLayer).style.display = 'none';
var strshowhide=0;
frmPanelStatus.location.href="panelstatus.asp?showhide=" +
strshowhide + "&whichLayer=" + whichLayer;
} else {
document.getElementById(whichLayer).style.display = 'inline';
var strshowhide=1;
frmPanelStatus.location.href="panelstatus.asp?showhide=" +
strshowhide + "&whichLayer=" + whichLayer;
}
}
<form name="frmCheckboxes">
<table border="0" width="95%" align="center">
<tr>
<td><input type="checkbox" name ="chkCompanyBoard"
onClick="hideLayer2('CompanyBoard',this);">Company and Board
Description</td>
<td><input type="checkbox" name ="chkEvents"
onClick="hideLayer2('Events',this);">Events Reported For This
Company</td>
<td><input type="checkbox" name ="chkAboutBoard"
onClick="hideLayer2('AboutBoard',this);">About the Board</td>
</tr>
<tr>
<td><input type="checkbox" name ="chkCommittees"
onClick="hideLayer2('Committees');">Current Committee Assignments</td>
<td><input type="checkbox" name ="chkTransactions"
onClick="hideLayer2('Transactions');">Related Party Transactions</td>
<td><input type="checkbox" name ="chkConnections"
onClick="hideLayer2('Connections');">Director Connections</td>
</tr>
</table>
</form>
<div id="CompanyBoard">stuff</div>
<div id="Events">stuff</div>
<div id="AboutBoard">stuff</div>