var checkedValues = $('.required:checked').map(function () {
return this.value;
}).get();
var arr = new Array(10);
alert(checkedValues);
alert("number of values in it " +checkedValues.length);
if (checkedValues.length > 1) {
alert("I am inside if ");
arr = checkedValues.split(',');
alert("I am done with the split ");
}
else {
arr = checkedValues;
alert("No split needed ");
}
$.getJSON('@Url.Action("testcata", "home")' + + '?Type=' + "@(Session["typ"])" + "&city=" + "@(Session["cit"])" + "&chkd=" + checkedValues,
function (data) {
//code
})
In controller :
public ActionResult testcata(string Type, int? city, int[] chkd)
{
//code
}
I am trying to get the values of check-boxes which are checked and store them in array which are then sent to controller through json function. alert("I am done with the split") is not being shown . Please help me.
checkedValuesis already an array. What are you trying to split?