jquery - How to get selected checkbox values in controller from formcollection? -


i passing form collection object 1 of controller via ajax this.

var formcollection = $(':input');     $.ajax({                 url: url,                 type: 'post',                 cache: false,                 async: true,                 data: formcollection,                 success: function (result) {                     // debugger                     if (result.status == true)                         document.getelementbyid('iframe211').src = "activationmodal.aspx"                  }             }) 

and in controller retreiving values this.

[httppost]     public actionresult assign(formcollection form)     {        var ch = form.getvalues("prints");          } 

here prints name of checkbox field defined in webgrid,

the problem here in variable ch not getting values of checkbox selected, getting checkbox values in array irrespective of whether selected or not.

how can values of checkbox selected?

thanks

you can modify selector following

var formcollection = $(':input:not(:checkbox), input:checked'); 

this controls not checkbox , checked checkboxes.


Comments