diff options
author | Mateja <mail@matejamaric.com> | 2020-10-01 22:39:38 +0200 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2020-10-01 22:39:38 +0200 |
commit | 110967fe02d337872508b2bba9cd48db138987ab (patch) | |
tree | 896928c7d7e83c7bd65e6f988284ecfa62637d36 /test/request.js | |
parent | 83ee4c20beabfc33a0572a053404d6c34319ade9 (diff) | |
download | old-php-yota-110967fe02d337872508b2bba9cd48db138987ab.tar.gz old-php-yota-110967fe02d337872508b2bba9cd48db138987ab.zip |
Work on button and styling...
Diffstat (limited to 'test/request.js')
-rw-r--r-- | test/request.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/request.js b/test/request.js new file mode 100644 index 0000000..bfcf592 --- /dev/null +++ b/test/request.js @@ -0,0 +1,38 @@ +function subAction(action, btn) { + trDom = btn.parentElement.parentElement; + trData = trDom.children; + + trId = trData[0].innerHTML; + trFrom = trData[1].innerHTML; + trTo = trData[2].innerHTML; + trName = trData[3].innerHTML; + + console.log(trId); + console.log(trFrom); + console.log(trTo); + console.log(trName); + + //for (var i = 0, len = trData.length - 1; i < len; i++) { + //console.log(i + ": " + trData[i].innerHTML); + //} + + if (action == 'delete') + if (confirm("Are you sure you want to delete this reservation?")) + trDom.remove(); + + // Send XHR + var xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function () { + if (this.readyState == 4 && this.status == 200) { + document.getElementById("notice").innerHTML = this.responseText; + } + } + xhttp.open("POST", "edit.inc.php", true); + xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); + data_str = "action=" + action + data_str += "&id=" + trId + data_str += "&from=" + trFrom + data_str += "&to=" + trTo + data_str += "&name=" + trName + xhttp.send(data_str); +} |