This is the answer I came up with. I basically had to write the code
twice, which is redundant, but I can't seem to get it to work any
other way:
Basically, the first section ties it to to the change and select
commands, whilst the second section needs to just run on the ready
event.

There has got to be a better way to do this; binding the handler with
the load OR ready event does not work. Any ideas or thoughts?

var parent_handler = function()
{
        var accepted_tos = function()
        {
                if ($("#accept_tos").is(":checked"))
                {
                        $("#hidden_agreements").fadeIn("medium");
                }
                else
                {
                        $("#submit").fadeOut("fast");
                        $("#hidden_agreements").fadeOut("fast");
                        $("#original_designer").attr('checked', false);
                        $("#original").attr('checked', false);
                        $("#not_selling_elsewhere").attr('checked', false);

                }
        }

        $("#accept_tos").bind("change click", accepted_tos)

        var agreements = function()
        {
                if ($("#original_designer").is(":checked") && $
("#original").is(":checked") && $
("#not_selling_elsewhere").is(":checked"))
                {
                        $("#submit").fadeIn("fast");
                }
                else
                {
                        $("#submit").fadeOut("fast");
                }
        }
        $("#original_designer").bind("change click", agreements)
        $("#original").bind("change click", agreements)
        $("#not_selling_elsewhere").bind("change click", agreements)


        // Default actions based on form selection
        if ($("#accept_tos").is(":checked"))
        {
                $("#hidden_agreements").show();
        }
        else
        {
                $("#submit").hide();
                $("#hidden_agreements").hide();
                $("#original_designer").attr('checked', false);
                $("#original").attr('checked', false);
                $("#not_selling_elsewhere").attr('checked', false);
        }

        if ($("#original_designer").is(":checked") && $
("#original").is(":checked") && $
("#not_selling_elsewhere").is(":checked"))
        {
                $("#submit").show();
        }
        else
        {
                $("#submit").hide();
        }

}
$(document).ready(parent_handler);

Reply via email to