looping thru a list of checkboxes and saving the values, now working properly

Posted by Erez on Stack Overflow See other posts from Stack Overflow or by Erez
Published on 2010-05-15T13:09:29Z Indexed on 2010/05/15 13:14 UTC
Read the original article Hit count: 170

Hello all,

I'm having a bit of a problem with this code.

The program gives me a list of checkboxes but a user ID. then u user can change his selection and push the save button (id="btnSaveUserIntersts") and i am trying to save in the hidden textbox all the values of the checkboxes that was choosen.

The problem is that i am getting all the time the same selections that came form the database and not getting the new selection that the user made.

Can any one tell me what am i doing wrong here?

$(document).ready(
function()
{ 
    $('#btnSaveUserIntersts').bind(
        'click',
        function()
        {
            var strCheckBoxChecked = new String();
            $('input[type=checkbox][checked]').each(
                function()
                {
                    strCheckBoxChecked += $(this).val();
                    strCheckBoxChecked += ',';
                }
            );
            $('#hidUserInterests').val(strCheckBoxChecked);
        }
    );
}

);

10x

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-selectors