Link to home
Start Free TrialLog in
Avatar of Luey
LueyFlag for United States of America

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");
		}
	  });
}

Open in new window

Avatar of Lukasz Chmielewski
Lukasz Chmielewski
Flag of Poland image

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;
        }
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Lukasz Chmielewski
Lukasz Chmielewski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Luey

ASKER

Thanks Roads works great
Thank you. It's all your code anyway :)
Avatar of Luey

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.