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

LueyAsked:
Who is Participating?
 
Lukasz ChmielewskiCommented:
...or updated with div first not shown.
http://jsfiddle.net/amfYz/1/
0
 
Lukasz ChmielewskiCommented:
0
 
dimajCommented:
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

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
LueyAuthor Commented:
Thanks Roads works great
0
 
Lukasz ChmielewskiCommented:
Thank you. It's all your code anyway :)
0
 
LueyAuthor Commented:
Duh I did not have the ID on my checkbox.  Kinda confused me at first since the code was the same.  Thanks again.
0
 
Lukasz ChmielewskiCommented:
An extra pair of eyes is sometimes enough, cheers.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.