Browse Source

résolution des problème de search

master
BARRAUX Arthur 3 years ago
parent
commit
dacc441067
  1. 2
      referant/js/edit.js
  2. 72
      referant/js/search.js
  3. 4
      referant/search.php

2
referant/js/edit.js

@ -36,10 +36,8 @@ function Edit(clas) {
let value = new Value(obj); let value = new Value(obj);
let xhr = new XMLHttpRequest(); let xhr = new XMLHttpRequest();
data.append('value', JSON.stringify(value)); data.append('value', JSON.stringify(value));
console.log(data);
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
console.log(this.response);
for (let i=1; i<11; i++) { for (let i=1; i<11; i++) {
obj[i].innerHTML = this.response[i]; obj[i].innerHTML = this.response[i];
} }

72
referant/js/search.js

@ -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)); })
} }

4
referant/search.php

@ -67,10 +67,6 @@ include '../session_restraintes.php';
<td>traitement</td> <td>traitement</td>
<td>valider</td> <td>valider</td>
</tr> </tr>
<?php
$class = 'ticket';
include 'include/line.php';
?>
</tbody> </tbody>
</table> </table>
</body> </body>

Loading…
Cancel
Save