JQuery:
var Arr = new Array()
var Selected = null;
if ($('#chk').is(':checked')) {
var List = $('#sellist option:selected');
$.each(List, function(index, item) {
Arr.push($(this).val());
});
Selected = Arr.join(',');
}
I have to pass Selected as a json parameter.When check box is checked Arr is not null so code work fine but when Arr is null or empty i am unable to pass as a parameter. I use "" instead of null but unable to solve the problem. How to handle this type of situation. Thanks.
I don’t understend where is the problem, becuase if i do:
i have no error, i have just an object with a property that has a null vale. Maybe you are doing something wrong when you create your object or maybe i am missing something.
EDIT – if the problem is the you must send it through ajax afterwards you can simply skip the parameter if is null an then check if the parameters exist server side or you could assign it the value
false