lundi 29 juin 2015

removing values of unchecked checkboxes

hi guys, I am having following code to generate a checkbox dynamically and get its value in the variable. The main problem faced by me is that I do not know how to remove the value from the variable once the checkbox is unchecked.

thanks I advance...

function getCheckBox(contentItem) {
        var checkbox = $("<input type='checkbox'/>");
        checkbox.css("height", "20");
        checkbox.css("width", "20");

        checkbox.change(function () {
            var checked = checkbox[0].checked;

            $(':checkbox').change(function () {
                if ($(this).is(':checked'))
                {
                    contentItem.value.details.checked = true;
                    global_audit_team = global_audit_team + contentItem.value.Name + ",";
                    alert(global_audit_team);
                }

                else
                {
                    contentItem.value.details.checked = false;
                    alert(contentItem.value.Name + " unchecked");
                }
            });


        });
        return checkbox;
    };




Aucun commentaire:

Enregistrer un commentaire