I would like to select from an array with multiple keys at the same time. Here is my dictionary:
var votes = {
"abreudia":{"ACDA":["alex"],"ANG":["lou"],"APL":["lea"],"ART":["cecile"],"ASR":["def"],"EC":["abc"],"EGOD":...,
"lou":{"ACDA":["abc"],"ANG":["def"],"APL":["hig"],"ART":["azerty"],"ASR":["def"],"EC":["abc"],"EGOD":...,
Here is my code so far:
var numChecked = 0;
var request = [];
function checkSelected(selected) {
if (selected.checked == true) {
request.push(selected.value);
numChecked += 1;
} else if (selected.checked == false) {
var index = request.indexOf(selected.value);
if (index !== -1) request.splice(index, 1);
numChecked -= 1;
}
console.log(
"selected : ",
selected.value,
"request : ",
request,
"numChecked : ",
numChecked
);
for (var key in votes) {
if (votes.hasOwnProperty(key)) {
console.log(key, votes[key][request]);
}
}
For example when I select "ASR" everything is fine and the output is the dictionary with only the "ASR". Like so:
"abreudia":"alex","lou":"abc",...
request : ["ASR"]
If I do more than one selection, request looks like:
request : ["ASR, ANG"]
In the end I would like an output like this with this request for example:
"abreudia":{"def", "lou"},"lou":{"def","def"},...