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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook 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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.