Luey
asked on
show/hide div with check box
I am trying to either show or hide a div depending on whether a checkbox is checked or not. Not having much luck.
// show hide element with check box
checkShow("confirm_check","confirm_button_box");
function checkShow(source,target) {
$("#"+source).click(function(){
// If checked
if ($("#"+source).is(":checked"))
{
//show the hidden div
$("#"+target).show("fast");
}
else
{
//otherwise, hide it
$("#"+target).hide("fast");
}
});
}
Here's a snippet from the freenas implementation of this:
function smart_enable_change() {
switch (document.iform.smart_enable.checked) {
case false:
showElementById('smart_extraoptions_tr','hide');
break;
case true:
showElementById('smart_extraoptions_tr','show');
break;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Roads works great
Thank you. It's all your code anyway :)
ASKER
Duh I did not have the ID on my checkbox. Kinda confused me at first since the code was the same. Thanks again.
An extra pair of eyes is sometimes enough, cheers.
http://jsfiddle.net/amfYz/