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.
24 lines
921 B
24 lines
921 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: 100px;" 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;
|
|
let xhr = new XMLHttpRequest();
|
|
data.append('value', JSON.stringify(value));
|
|
xhr.onreadystatechange = function() {
|
|
if (this.readyState == 4 && this.status == 200) {
|
|
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);
|
|
}
|
|
}
|
|
|