diff --git a/css/profile.css b/css/profile.css index ea790e758899f7a64bc143a1eea81103f6b57013..94dbd5cff904004445f89624a545f7fb4bd0bf6b 100644 --- a/css/profile.css +++ b/css/profile.css @@ -260,7 +260,7 @@ td:nth-of-type(2n-1) { } .data-location .delete { - color: #B33A3A; + color: red; font-weight: bold; float: right; margin-right: 10px; diff --git a/editpreferredlocations.php b/editpreferredlocations.php index ac74cd8115c2d5c0f71d15464710cda1b00aae9c..ca6ad719b98a34c8bbcd052c33357feff278b7d0 100644 --- a/editpreferredlocations.php +++ b/editpreferredlocations.php @@ -39,6 +39,7 @@ if(isset($_POST["submit"])) { $sql = "SELECT location FROM driver_locations WHERE ID=$id_active"; $result = mysqli_query($conn, $sql); +echo "<script>var id = " . $id_active . ";</script>" ?> <!DOCTYPE html> diff --git a/js/editlocation.js b/js/editlocation.js index 52f52983327f3c54d76e945e238993b98f001477..2123dc446abf48e2387806ed40f7d00109981e50 100644 --- a/js/editlocation.js +++ b/js/editlocation.js @@ -10,7 +10,7 @@ function editLocation(elmt){ row.children[2].children[1].children[0].onclick = function(){ cancelLocation(elmt, textBefore)}; } -function saveLocation(elmt, text){ +function saveLocation(elmt, textBefore){ var row = elmt.parentElement.parentElement.parentElement; row.children[1].children[0].disabled = true; row.children[2].children[0].children[0].innerHTML = "mode_edit"; @@ -19,6 +19,16 @@ function saveLocation(elmt, text){ row.children[2].children[1].children[0].style.color = "red"; row.children[2].children[0].children[0].onclick = function(){ editLocation(elmt)}; row.children[2].children[1].children[0].onclick = function(){ deleteLocation(elmt)}; + var text = encodeURI(row.children[1].children[0].value); + textBefore = encodeURI(textBefore); + var xmlhttp = new XMLHttpRequest(); + if(!xmlhttp){ + return; + } + var url = "editlocationhandler.php?id_active="+ id + "&update=" + text + "&location=" + textBefore; + xmlhttp.open("GET", url, true); + xmlhttp.send(); + location.reload(); } function cancelLocation(elmt, text){ @@ -36,6 +46,14 @@ function cancelLocation(elmt, text){ function deleteLocation(elmt){ if (confirm("Are you sure deleting the location ?") == true) { var row = elmt.parentElement.parentElement.parentElement; - + var text = encodeURI(row.children[1].children[0].value); + var xmlhttp = new XMLHttpRequest(); + if(!xmlhttp){ + return; + } + var url = "editlocationhandler.php?id_active="+ id + "&delete=" + text; + xmlhttp.open("GET", url, true); + xmlhttp.send(); + location.reload(); } } \ No newline at end of file