I am trying to add values here:
var selected_value = {
addtypeid: addtypeid,
isnew: isnew,
geographicareaid: geographicareaid,
catid: catid,
catid2: catid2,
manufacturerid: manufacturerid,
modelid: modelid,
yearofmanufacturing_from: yearofmanufacturing_from,
yearofmanufacturing_to: yearofmanufacturing_to,
};
using this code:
var categories = [];
$("input[name='categoriesfilters[]']:checked").each(function () {
var id = $(this).attr("id");
var value = $(this).val();
categories[categories.length] = {
id: value
};
});
$.each(categories, function (id, value) {
//alert('id : ' + id + 'value:' + value);
selected_value.id = value;
});
however, only the last checked checkbox is added in the following format:
id[id] 166
while i would like to have there all the checkboxes in the format:
166:166,
Anyone can help me with this?
Regards, John
categories[categories.length] = { id: value };tocategories[categories.length] = { 'id': id, 'value': value };id: []andvalue: []properties into your object 'selected_value' and then you can useselected_value.id.push(value)andselected_value.value.push(value)