Created
October 11, 2020 21:19
-
-
Save InersIn/ed1f2f7ed3bc8af3ef8c12421861fc35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(s, objectName) { | |
setupLinks = function() { | |
if (s.admin) { | |
var sl = document.getElementsByClassName("student-link"); | |
for (i = 0; i < sl.length; i++) { | |
let name = sl[i].innerHTML; | |
sl[i].style.cursor = 'pointer'; | |
sl[i].addEventListener("click", function() { | |
window.location = '/update-' + objectName + '/' + this.dataset.id; | |
}); | |
} | |
} | |
}; | |
updateForm = function() { | |
var submitButton = document.getElementsByClassName("update-record"); | |
if (submitButton.length === 1) { | |
submitButton[0].addEventListener("click", function() { | |
var english = document.getElementById("english"); | |
english = english.options[english.selectedIndex].value; | |
var science = document.getElementById("science"); | |
science = science.options[science.selectedIndex].value; | |
var maths = document.getElementById("maths"); | |
maths = maths.options[maths.selectedIndex].value; | |
var grades = new Set(["A", "B", "C", "D", "E", "F"]); | |
if (grades.has(english) && grades.has(science) && grades.has(maths)) { | |
document.getElementById('student-form').submit(); | |
} else { | |
alert('Grades should only be between A - F'); | |
} | |
}); | |
} | |
}; | |
setupLinks(); | |
updateForm(); | |
})(staff, 'student'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment