jquery get radiobuttonlist by id dynamically

Posted by Cindy on Stack Overflow See other posts from Stack Overflow or by Cindy
Published on 2010-06-11T14:00:00Z Indexed on 2010/06/11 14:03 UTC
Read the original article Hit count: 245

Filed under:

I have two radiobuttonlist and one checkboxlist on the page. Ideally based on the checkbox selected value, I want to enable/disable corresponding radibuttonlist with jquery function.

But some how $("input[name*=" + columnName + "]") always return null. It can not find the radiobuttonlist by its name?

    $(function() {
        function checkBoxClicked() {

            var isChecked = $(this).is(":checked");
            var columnName = "rblColumn" + $(this).parent().attr("alt");

            if (isChecked) {
                $("input[name*=" + columnName + "]").removeAttr("disabled");
            } else {
                $("input[name*=" + columnName + "]").attr("disabled", "disabled");

                $("input[name*=" + columnName + "] input").each(function() {
                    $(this).attr("checked", "")
                });

            }

        }

        //intercept any check box click event inside the #list Div
        $(":checkbox").click(checkBoxClicked);
    });

© Stack Overflow or respective owner

Related posts about jQuery