formulaire pour remplir des ticket de panne
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.

63 lines
2.2 KiB

3 years ago
var tr = '';
document.getElementById('form').addEventListener('submit', function(e) {
e.preventDefault();
3 years ago
// try {
// while (document.getElementsByName('tr')) {
// document.getElementsByName('tr')[0].remove();
// }
// } catch (e) {
//
// }
let data = new FormData(this);
3 years ago
console.log(data);
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
if (this.response != false) {
3 years ago
this.response.forEach((item, i) => {
console.log(push_line(item[0]));
console.log('salut' + tr);
document.getElementsByTagName('tbody')[0].innerHTML = tr;
let ticket = document.getElementsByClassName("'" + item[0] + "'");
console.log(ticket);
for (let i=0; i < 11; i++) {
ticket[i].textContent = item[i];
}
if (item[11] == 1) {
ticket[11].querySelector('img').src = "../img/check.png";
}
else {
ticket[11].querySelector('img').src = "../img/excla.png";
}
document.getElementsByTagName('table')[0].style.display = 'block';
});
}
else {
alert("Ce ticket n'existe pas");
}
} else if (this.readyState == 4) {
alert('uhe erreur est survenue...');
}
};
xhr.open('POST', 'cible/search.php', true);
xhr.responseType = 'json';
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
3 years ago
xhr.send("champ=" + encodeURI(data.get('champ')) + "&" + "value=" + encodeURI(data.get('value')));
});
3 years ago
function push_line(clas) {
let xhr = new XMLHttpRequest();
xhr.open('POST', 'include/line.php', true);
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
tr = this.response;
console.log(tr);
return tr;
}
}
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send("class=" + encodeURI(clas));
}