-
Notifications
You must be signed in to change notification settings - Fork 2
/
separateOffVicFunction
57 lines (43 loc) · 2.38 KB
/
separateOffVicFunction
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
function returnCountOff() {
document.getElementById("resultsOffenders").textContent = "";
document.getElementById("totalCountOffenders").textContent = "";
let newData = JSON.parse(dataResponseOffenderObj.textForResponse);
let yearInput = document.getElementById("crimeForm")['year'].value
let ethnicityInput = document.getElementById("crimeForm")['ethnicity'].value
let totalNumberOffenders = 0;
for (let i = 0; i <= newData.results.length - 1; i++) {
let yearResults = newData.results[i].year;
let ethnicityResults = newData.results[i].ethnicity
if ((yearInput == yearResults && ethnicityInput == ethnicityResults) ||
(yearInput == yearResults && ethnicityInput == "") ||
(ethnicityInput == ethnicityResults && yearInput == "")
) {
document.getElementById("search_results").innerHTML += "<strong>Year: </strong>" + newData.results[i].year + "<br>" + "<strong>Ethnicity: </strong>" + newData.results[i].ethnicity + "<br>";
totalNumberOffenders += newData.results[i].count
document.getElementById("total_count").innerHTML = totalNumberOffenders
}
}
return totalNumberOffenders;
}
function returnCountVic() {
document.getElementById("resultsVictims").textContent = "";
document.getElementById("totalCountVictims").textContent = "";
let newData = JSON.parse(dataResponseVictimObj.textForResponse);
let yearInput = document.getElementById("crimeForm")['year'].value
let ethnicityInput = document.getElementById("crimeForm")['ethnicity'].value
let totalNumberVictims = 0;
for (let i = 0; i <= newData.results.length - 1; i++) {
let yearResults = newData.results[i].year;
let ethnicityResults = newData.results[i].ethnicity
if ((yearInput == yearResults && ethnicityInput == ethnicityResults) ||
(yearInput == yearResults && ethnicityInput == "") ||
(ethnicityInput == ethnicityResults && yearInput == ""))
{
document.getElementById("search_resultsv").innerHTML += "<strong>Year: </strong>" + newData.results[i].year + "<br>" + "<strong>Ethnicity: </strong>" + newData.results[i].ethnicity + "<br>";
totalNumberVictims += newData.results[i].count
document.getElementById("total_countv").innerHTML = totalNumberVictims
}
}
return totalNumberVictims;
}*/