You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.4 KiB
68 lines
2.4 KiB
3 years ago
|
let checkbox = document.getElementsByClassName('checkbox');
|
||
|
for (elem in checkbox) {
|
||
|
elem.checked = false;
|
||
|
}
|
||
|
|
||
|
function Slider(id) {
|
||
|
let td = document.getElementsByClassName(id);
|
||
|
let is_checked;
|
||
|
if (td[12].querySelector('input').checked == true) {
|
||
|
is_checked = 1;
|
||
|
}
|
||
|
else {
|
||
|
is_checked = 0;
|
||
|
}
|
||
|
let xhr = new XMLHttpRequest();
|
||
|
xhr.onreadystatechange = function() {
|
||
|
if (this.readyState == 4 && this.status == 200) {
|
||
|
td[11].textContent = this.response;
|
||
|
}
|
||
|
};
|
||
|
xhr.open('POST', 'cible/index.php', true);
|
||
|
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||
|
xhr.send("is_checked=" + encodeURI(is_checked) + "&id=" + encodeURI(id));
|
||
|
}
|
||
|
|
||
|
function Edit(clas) {
|
||
|
let obj = document.getElementsByClassName(clas);
|
||
|
let data = new FormData();
|
||
|
if (obj[13].querySelector('input').value == 'edit') {
|
||
|
for (let i=1; i< 12; i++) {
|
||
|
obj[i].innerHTML = '<input type="text" style="width: 80%;" value="' + obj[i].textContent + '">';
|
||
|
}
|
||
|
obj[13].querySelector('input').value = 'ok';
|
||
|
}
|
||
|
else {
|
||
|
let value = new Value(obj);
|
||
|
let xhr = new XMLHttpRequest();
|
||
|
data.append('value', JSON.stringify(value));
|
||
|
console.log(data);
|
||
|
xhr.onreadystatechange = function() {
|
||
|
if (this.readyState == 4 && this.status == 200) {
|
||
|
console.log(this.response);
|
||
|
for (let i=1; i<12; i++) {
|
||
|
obj[i].innerHTML = this.response[i];
|
||
|
}
|
||
|
obj[13].querySelector('input').value = 'edit';
|
||
|
}
|
||
|
};
|
||
|
xhr.open('POST', 'cible/edit.php', true);
|
||
|
xhr.responseType = 'json';
|
||
|
xhr.send(data);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function Value(list) {
|
||
|
this.id = list[0].textContent;
|
||
|
this.dates = list[1].querySelector('input').value;
|
||
|
this.details = list[2].querySelector('input').value;
|
||
|
this.lieu = list[3].querySelector('input').value;
|
||
|
this.salle = list[4].querySelector('input').value;
|
||
|
this.pos = list[5].querySelector('input').value;
|
||
|
this.materiel = list[6].querySelector('input').value;
|
||
|
this.marque = list[7].querySelector('input').value;
|
||
|
this.model = list[8].querySelector('input').value;
|
||
|
this.nserie = list[9].querySelector('input').value;
|
||
|
this.demandeur = list[10].querySelector('input').value;
|
||
|
this.traitement = list[11].querySelector('input').value;
|
||
|
}
|