|
@ -1,36 +1,32 @@ |
|
|
var tr = ''; |
|
|
|
|
|
|
|
|
|
|
|
document.getElementById('form').addEventListener('submit', function(e) { |
|
|
document.getElementById('form').addEventListener('submit', function(e) { |
|
|
e.preventDefault(); |
|
|
e.preventDefault(); |
|
|
// try {
|
|
|
|
|
|
// while (document.getElementsByName('tr')) {
|
|
|
let tableBody = document.getElementsByTagName('tbody')[0]; // on raffraichie le tableau en enlevant les precedentes lignes
|
|
|
// document.getElementsByName('tr')[0].remove();
|
|
|
if (tableBody.children.length > 1) { |
|
|
// }
|
|
|
for (let i = 1; i < tableBody.children.length; i++) { |
|
|
// } catch (e) {
|
|
|
tableBody.removeChild(tableBody.children[i]); |
|
|
//
|
|
|
} |
|
|
// }
|
|
|
} |
|
|
let data = new FormData(this); |
|
|
|
|
|
console.log(data); |
|
|
let data = new FormData(this); // on récupère le formulaire
|
|
|
|
|
|
|
|
|
let xhr = new XMLHttpRequest(); |
|
|
let xhr = new XMLHttpRequest(); |
|
|
xhr.onreadystatechange = function() { |
|
|
xhr.onreadystatechange = function() { |
|
|
if (this.readyState == 4 && this.status == 200) { |
|
|
if (this.readyState == 4 && this.status == 200) { |
|
|
if (this.response != false) { |
|
|
if (this.response != false) { |
|
|
this.response.forEach((item, i) => { |
|
|
this.response.forEach((item) => { |
|
|
console.log(push_line(item[0])); |
|
|
pull_line(item[0]).then((value) => { |
|
|
console.log('salut' + tr); |
|
|
let ticket = document.getElementsByClassName(item[0]); |
|
|
document.getElementsByTagName('tbody')[0].innerHTML = tr; |
|
|
for (let i=0; i < 11; i++) { |
|
|
let ticket = document.getElementsByClassName("'" + item[0] + "'"); |
|
|
ticket[i].textContent = item[i]; |
|
|
console.log(ticket); |
|
|
} |
|
|
for (let i=0; i < 11; i++) { |
|
|
if (item[11] == 1) { |
|
|
ticket[i].textContent = item[i]; |
|
|
ticket[11].querySelector('img').src = "../img/check.png"; |
|
|
} |
|
|
} |
|
|
if (item[11] == 1) { |
|
|
else { |
|
|
ticket[11].querySelector('img').src = "../img/check.png"; |
|
|
ticket[11].querySelector('img').src = "../img/excla.png"; |
|
|
} |
|
|
} |
|
|
else { |
|
|
}); |
|
|
ticket[11].querySelector('img').src = "../img/excla.png"; |
|
|
|
|
|
} |
|
|
|
|
|
document.getElementsByTagName('table')[0].style.display = 'block'; |
|
|
document.getElementsByTagName('table')[0].style.display = 'block'; |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
@ -47,16 +43,18 @@ document.getElementById('form').addEventListener('submit', function(e) { |
|
|
xhr.send("champ=" + encodeURI(data.get('champ')) + "&" + "value=" + encodeURI(data.get('value'))); |
|
|
xhr.send("champ=" + encodeURI(data.get('champ')) + "&" + "value=" + encodeURI(data.get('value'))); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
function push_line(clas) { |
|
|
function pull_line(clas) { |
|
|
let xhr = new XMLHttpRequest(); |
|
|
return new Promise((resolve, reject) => { |
|
|
xhr.open('POST', 'include/line.php', true); |
|
|
let xhr = new XMLHttpRequest(), method = 'POST', file = 'include/line.php'; |
|
|
xhr.onreadystatechange = function() { |
|
|
xhr.open(method, file, true); |
|
|
if (this.readyState == 4 && this.status == 200) { |
|
|
xhr.onreadystatechange = function() { |
|
|
tr = this.response; |
|
|
if (this.readyState == 4 && this.status == 200) { |
|
|
console.log(tr); |
|
|
resolve(document.getElementsByTagName('tbody')[0].innerHTML += this.response); |
|
|
return tr; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
|
|
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
|
|
xhr.send("class=" + encodeURI(clas)); |
|
|
xhr.send("class=" + encodeURI(clas)); |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|