I'm having some trouble creating a multidimensional array where im putting some counties and places that are in the county.
Example of what im trying to do:
[
'HEDMARK' => [
1 => 'ELVERUM',
2 => 'HAMAR
],
'OSLO' => [
1 => 'OSLO'
]
]
The code im using is this:
var $query_place = [];
// Get each checked county
$.each($('.county input:checkbox:checked'), function () {
$query_place.push({
county: $(this).val(),
postal: []
});
});
// Get each checked postal
$.each($('.postal input:checkbox:checked'), function() {
$query_place[$(this).attr('data-county')].postal.push();
});
The error im getting in the console is this:
TypeError: $query_place[$(...).attr(...)] is undefined
Is there something im forgetting here? Or have i just done this wrong?

$().data( attributeName )better, and mind thecountytypo perhaps ^^$().datainstead, but I get the same error. I tried to switch the the inside of$.eachpostal line toalert($(this).val());but it doesn't alert anything, so i think i can't use $(this) for some reason.$query_place.county[$(this).attr('data-county')].postal.push($(this).val());