Skip to content
Snippets Groups Projects

11- 13515040 - Patrick Nugroho Hadiwinoto

Open Martin Lutta requested to merge 1SleepNotFound/TugasBesar1_2017:master into master
Viewing commit e1ba2c39
Show latest version
5 files
+ 91
26
Preferences
Compare changes
Files
5
function editLoc(){
var field = document.getElementById("newlocations");
var location = document.getElementById("locations");
var check = document.getElementById("check-button-row1");
var edit = document.getElementById("edit-button-rowl");
var del = document.getElementById("remove-button-row1");
field.type="text";
check.setAttribute("style","display:inline");
location.setAttribute("style","display:none");
edit.setAttribute("style","display:none");
del.setAttribute("style","display:inline");
}
function changeToInput(item) {
var changeButton = item.previousSibling.previousSibling;
changeButton.style.display = "inline";
item.style.display = "none";
var row = (item.parentElement.parentElement.children)[1];
var inputText = (row.children)[0];
var labelText = (row.children)[1];
inputText.type = "text";
labelText.style.display = "none";
}
function updatePreferredLocation(item) {
var row = (item.parentElement.parentElement.children)[1];
var newlocation = ((row.children)[0]).value;
var id = ((row.children)[2]).value;
var no = ((row.children)[3]).value;
if (newlocation != "") {
var xmlhttp = getXMLHTTP();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
window.location.href = "edit_preferred_locations.php?id_active=" + id;
}
};
xmlhttp.open("GET", "update_preferred_locations.php?id=" + id + "&no=" + no + "&location-input=" + newlocation, true);
xmlhttp.send();
} else {
var inputText = (row.children)[0];
var labelText = (row.children)[1];
inputText.type = "hidden";
labelText.style.display = "inline";
var editButton = item.nextSibling.nextSibling;
editButton.style.display = "inline";
item.style.display = "none";
}
}
function deleteItem(item) {
var row = (item.parentElement.parentElement.children)[1];
var prefLocation = ((row.children)[1]).innerText;
var id = ((row.children)[2]).value;
var no = ((row.children)[3]).value;
var confirmation = confirm("Are you sure to delete " + prefLocation + "?");
if (confirmation) {
var xmlhttp = getXMLHTTP();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
window.location.href = "edit_preferred_locations.php?id_active=" + id;
}
};
xmlhttp.open("GET", "delete_preferred_locations.php?no=" + no, true);
xmlhttp.send();
}
}
function getXMLHTTP() {
var xmlhttp;