1

I check my checkbox in the Form and i save it! but in the sharepoint list i find that the value is usual No! when i don't check it it's empty in the list.

I want if i check i find yes if not i find No.

this is my code :

function Save() 
{
    var Regulated = $('input[name=Regulated]:checked').val();
    var oList = web.get_lists().getByTitle("PendingList");
    var item = oList.addItem(new SP.ListItemCreationInformation());
    item.set_item('Regulated', Regulated);
    item.update();  
    context.executeQueryAsync(
        Function.createDelegate(this,this.onQuerySucceeded_SaveTo),
        Function.createDelegate(this, this.onQueryFailed_SaveTo)
    );
}
2

$('input[name=Regulated]').is(':checked') will give you a proper boolean value whereas $('input[name=Regulated]:checked').val() returns 'on' when checked and undefined when unchecked. Try the updated code below:

function Save() {
    var Regulated = $('input[name=Regulated]').is(':checked');
    var oList = web.get_lists().getByTitle("PendingList");
    var item = oList.addItem(new SP.ListItemCreationInformation());
    item.set_item('Regulated', Regulated);
    item.update();  
    clientContext.executeQueryAsync(
        Function.createDelegate(this,this.onQuerySucceeded_SaveTo),
        Function.createDelegate(this, this.onQueryFailed_SaveTo)
    );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.