WEB/Praktikum2/ppm1/static/functions.js

35 lines
904 B
JavaScript
Raw Normal View History

2016-11-07 17:59:41 +01:00
var table = document.getElementById('idList');
var selected = table.getElementsByClassName('selected');
var selectedId = 'None';
table.onclick = highlight;
2016-11-16 16:52:00 +01:00
function select(category, mode) {
2016-11-07 17:59:41 +01:00
var id = selectedId;
if (id == 'None')
{
alert("Kein Eintrag ausgewaehlt!");
}
else
{
2016-11-16 16:52:00 +01:00
if(mode == 0){
2016-11-07 17:59:41 +01:00
window.location.href = '/detail/?cat=' + category + '&id=' + id;
2016-11-16 16:52:00 +01:00
}
else {
var result = confirm("Sind Sie sicher, dass der Eintrag gelöscht werden soll?");
if(result) {
window.location.href = '/delete/?cat=' + category + '&id=' + id;
return true;
}
else {
return false;
}
}
2016-11-07 17:59:41 +01:00
}
}
function highlight(e) {
if (selected[0]) selected[0].className = '';
e.target.parentNode.className = 'selected';
var tr = e.target.parentNode;
selectedId = tr.getAttribute('id');
}