|
@ -1,27 +1,22 @@ |
|
|
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; |
|
|
|
|
|
let ticket = document.getElementsByClassName("'" + item[0] + "'"); |
|
|
|
|
|
console.log(ticket); |
|
|
|
|
|
for (let i=0; i < 11; i++) { |
|
|
for (let i=0; i < 11; i++) { |
|
|
ticket[i].textContent = item[i]; |
|
|
ticket[i].textContent = item[i]; |
|
|
} |
|
|
} |
|
@ -31,6 +26,7 @@ document.getElementById('form').addEventListener('submit', function(e) { |
|
|
else { |
|
|
else { |
|
|
ticket[11].querySelector('img').src = "../img/excla.png"; |
|
|
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.open(method, file, true); |
|
|
xhr.onreadystatechange = function() { |
|
|
xhr.onreadystatechange = function() { |
|
|
if (this.readyState == 4 && this.status == 200) { |
|
|
if (this.readyState == 4 && this.status == 200) { |
|
|
tr = this.response; |
|
|
resolve(document.getElementsByTagName('tbody')[0].innerHTML += this.response); |
|
|
console.log(tr); |
|
|
|
|
|
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)); |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|