diff --git a/static/index.js b/static/index.js index 1bfd103..09acbcb 100644 --- a/static/index.js +++ b/static/index.js @@ -18,6 +18,7 @@ function load_teachers(id) { fetch(`/api/professori?id=${id}`) .then((response) => response.json()) .then((data) => { + sessionStorage.setItem("teachers", JSON.stringify(data)); let i = 0; data.forEach((el) => { const select = document.getElementById("teachers"); @@ -151,8 +152,13 @@ function load_major() { } function select_teacher() { + let teacher = document.getElementById("teacher").value; + let teachers = JSON.parse(sessionStorage.getItem("teachers")); + if (!teachers.includes(teacher)) { + return false; + } Cookies.set("type", "teacher"); - Cookies.set("teacher", document.getElementById("teacher").value); + Cookies.set("teacher", teacher); } function select_class() {