[jQuery] Dynamic Variables

[jQuery] Dynamic Variables


Hi,
I hope someone can help me out a bit.
I am finding myself doing a lot of code (as I'll paste below). It's
basically the same block of code with different variables.
What I am trying to do is consolidate all that code into a funciton
where I can declare all the checkboxes I need to create an Click
function for, and then loop through them and generate the click
handler as well as other functions for all of them.
Here is the code snippet:
$('#ckbx_wgmpo').click(
                function() {
                    if ($(this).attr("checked") == true){
                        $('table#tbl_wgmpo').show('medium');
                    }
                    else{
                        $('table#tbl_wgmpo').hide('medium');
                    }
                }
            );
            $('#ckbx_wgmse').click(
                function() {
                    if ($(this).attr("checked") == true){
                        $('table#tbl_wgmse').show('medium');
                    }
                    else{
                        $('table#tbl_wgmse').hide('medium');
                    }
                }
            );
            $('#ckbx_wgmoe').click(
                function() {
                    if ($(this).attr("checked") == true){
                        $('table#tbl_wgmoe').show('medium');
                    }
                    else{
                        $('table#tbl_wgmoe').hide('medium');
                    }
                }
            );
            $('#ckbx_tyd').click(
                function() {
                    if ($(this).attr("checked") == true){
                        $('div#tyd_info').show('medium');
                    }
                    else{
                        $('div#tyd_info').hide('medium');
                    }
                }
            );
            $('#ckbx_tydpo').click(
                function() {
                    if ($(this).attr("checked") == true){
                        $('table#tbl_tydpo').show('medium');
                    }
                    else{
                        $('table#tbl_tydpo').hide('medium');
                    }
                }
            );
            $('#ckbx_tydgc').click(
                function() {
                    if ($(this).attr("checked") == true){
                        $('table#tbl_tydgc').show('medium');
                    }
                    else{
                        $('table#tbl_tydgc').hide('medium');
                    }
                }
            );
            $('#ckbx_tydoe').click(
                function() {
                    if ($(this).attr("checked") == true){
                        $('table#tbl_tydoe').show('medium');
                    }
                    else{
                        $('table#tbl_tydoe').hide('medium');
                    }
                }
            );