89 lines
2.1 KiB
JavaScript
89 lines
2.1 KiB
JavaScript
let numbergak = document.getElementById("gaknumber")
|
|
let predsel = document.getElementById('predesdatel')
|
|
let uch1 = document.getElementById('uchgak1')
|
|
let uch2 = document.getElementById('uchgak2')
|
|
let uch3 = document.getElementById('uchgak3')
|
|
let uch4 = document.getElementById('uchgak4')
|
|
let addcom = document.getElementById("addcom")
|
|
|
|
let secretar = document.getElementById('secretar')
|
|
|
|
let preds = []
|
|
let alluchs = []
|
|
let secretars = []
|
|
|
|
$(document).ready(function () {
|
|
console.log("page Load!!")
|
|
|
|
$.getJSON("/gu", function (data) {
|
|
data.forEach(function (element) {
|
|
if (element.secretar == 0) {
|
|
alluchs.push(element.fio)
|
|
} else {
|
|
secretars.push(element.fio)
|
|
}
|
|
|
|
if (element.predsed == 1) {
|
|
preds.push(element.fio)
|
|
}
|
|
|
|
});
|
|
|
|
console.log(preds)
|
|
console.log(secretars)
|
|
console.log(alluchs)
|
|
|
|
preds.forEach( function (item) {
|
|
let newOption = new Option(item, item)
|
|
predsel.appendChild(newOption)
|
|
})
|
|
|
|
|
|
secretars.forEach(function (item) {
|
|
let newOption = new Option(item, item)
|
|
secretar.appendChild(newOption)
|
|
})
|
|
|
|
|
|
alltagych = Array.from( $('select[id^="uchgak"]'))
|
|
|
|
|
|
alltagych.forEach(function (alltagychItem) {
|
|
alluchs.forEach(function (item) {
|
|
const option = document.createElement('option');
|
|
option.value = item;
|
|
option.textContent = item;
|
|
alltagychItem.appendChild(option)
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
addcom.onclick = function () {
|
|
console.log('PRESSEDD')
|
|
|
|
$.ajax({
|
|
url: "/addcommision",
|
|
type: "get",
|
|
contentType: "application/json",
|
|
dataType: "json",
|
|
data: {
|
|
'predsdatel': predsel.value,
|
|
'uchastnik1': uch1.value,
|
|
'uchastnik2': uch2.value,
|
|
'uchastnik3': uch3.value,
|
|
'uchastnik4': uch4.value,
|
|
'secretar': secretar.value
|
|
},
|
|
error: function (error) {
|
|
console.log(error);
|
|
}
|
|
})
|
|
|
|
|
|
} |