I have location name and location Id in database table. Using foreach loop i\'m printing the values in checkbox in PHP. I have a submit button which triggers a javascript. I
This is a variation to get all checked checkboxes in all_location_id
without using an "if" statement
var all_location_id = document.querySelectorAll('input[name="location[]"]:checked');
var aIds = [];
for(var x = 0, l = all_location_id.length; x < l; x++)
{
aIds.push(all_location_id[x].value);
}
var str = aIds.join(', ');
console.log(str);