Calling Two Functions

E

evanburen

When I click on the "Check All" checkbox, it correctly checks all of
the boxes in my form, but I would like each checkbox to also call
hideLayer2 function just as
what would occur if the user checked the boxes individually. Is there
a way to call the hideLayer2 function and pass the correct whichLayer
and the_box parameters
within the DoToAll function? Maybe there is an easier way? Thanks.


<form name="frmCheckboxes" action="panelstatus.asp" method="post">

<input type="checkbox" onclick="DoToAll(this)">Check All:
<input type="checkbox" name ="chkCompanyBoard"
onClick="hideLayer2('CompanyBoard',this);">Company and Board
Description<br />
<input type="checkbox" name ="chkEvents"
onClick="hideLayer2('Events',this);">Events Reported For This
Company<br />
<input type="checkbox" name ="chkAboutBoard"
onClick="hideLayer2('AboutBoard',this);">About the Board<br />

</form>


function DoToAll(obj_input)
{ bol_is_checked = (obj_input.checked)?true:false
for (x=0;x<obj_input.form.length;x++)
{ obj_input.form.elements[x].checked = bol_is_checked;
}
}


function hideLayer2(whichLayer,the_box)
{
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;

}
}
 
L

Lee

(e-mail address removed) said:
When I click on the "Check All" checkbox, it correctly checks all of
the boxes in my form, but I would like each checkbox to also call
hideLayer2 function just as
what would occur if the user checked the boxes individually. Is there
a way to call the hideLayer2 function and pass the correct whichLayer
and the_box parameters
within the DoToAll function? Maybe there is an easier way? Thanks.


<form name="frmCheckboxes" action="panelstatus.asp" method="post">

<input type="checkbox" onclick="DoToAll(this)">Check All:
<input type="checkbox" name ="chkCompanyBoard"
onClick="hideLayer2('CompanyBoard',this);">Company and Board
Description<br />
<input type="checkbox" name ="chkEvents"
onClick="hideLayer2('Events',this);">Events Reported For This
Company<br />
<input type="checkbox" name ="chkAboutBoard"
onClick="hideLayer2('AboutBoard',this);">About the Board<br />

</form>


function DoToAll(obj_input)
{ bol_is_checked = (obj_input.checked)?true:false
for (x=0;x<obj_input.form.length;x++)
{ obj_input.form.elements[x].checked = bol_is_checked;
}
}


function hideLayer2(whichLayer,the_box)

Assuming that your checkbox names are always of the form "chk<LayerName>",
your hideLayer2() function can extract the layer name from the checkbox
name:

In the checkboxes:
onclick="hideLayer2(this)"

In DoToAll():
{
obj_input.form.elements[x].checked = bol_is_checked;
hideLayer2(obj_input.form.elements[x]);
}

in hideLayer2():

function hideLayer2(the_box)
{
whichLayer = the_box.name.substring(3);
...
 
E

evanburen

Thanks again Lee. I'm getting the error message 'Object required'

function DoToAll(obj_input)
{ bol_is_checked = (obj_input.checked)?true:false
for (x=0;x<obj_input.form.length;x++)
{ obj_input.form.elements[x].checked = bol_is_checked;
hideLayer2(obj_input.form.elements[x]);
}
}


function hideLayer2(the_box)
{
// var the_box = window.document.frmCheckboxes.chkCompanyBoard;
// var the_switch = "";
if (the_box.checked == false) {
whichLayer = the_box.name.substring(3);
document.getElementById(whichLayer).style.display = 'none';
var strshowhide=0;
frmPanelStatus.location.href="panelstatus.asp?showhide=" +
strshowhide + "&whichLayer=" + whichLayer;
} else {
whichLayer = the_box.name.substring(3);
document.getElementById(whichLayer).style.display = 'inline';
var strshowhide=1;
frmPanelStatus.location.href="panelstatus.asp?showhide=" +
strshowhide + "&whichLayer=" + whichLayer;

}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top