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.

26 lines
990 B

function Edit(clas) {
let obj = document.getElementsByClassName(clas);
let data = new FormData();
if (obj[2].querySelector('input').value == 'edit') {
obj[1].innerHTML = '<input type="text" style="width: 80%;" value="' + obj[1].textContent + '">';
obj[2].querySelector('input').value = 'ok';
}
else {
let value = {};
value.login = obj[0].textContent;
value.pwd = obj[1].querySelector('input').value;
console.log(value);
let xhr = new XMLHttpRequest();
data.append('value', JSON.stringify(value));
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(this.response);
obj[1].innerHTML = this.response[1];
obj[2].querySelector('input').value = 'edit';
}
};
xhr.open('POST', 'cible/admin.php', true);
xhr.responseType = 'json';
xhr.send(data);
}
}