//JavaScript File for athlete_survey.php written by Joseph Davy //Serves to make the help buttons work as well as the slider value. //the following are variables connected to each question's help button. //var doc = document.getElementById("test"); var phys = document.getElementById("phys"); var acad = document.getElementById("acad"); var perf = document.getElementById("perf"); var rela = document.getElementById("rela"); var slee = document.getElementById("slee"); var meet = document.getElementById("meet"); //These are listeners set up to wait for the next click event. This is for the help buttons next to the question. //doc.addEventListener("click", physical); phys.addEventListener("click", physical); acad.addEventListener("click", academic); perf.addEventListener("click", perform); rela.addEventListener("click", relation); slee.addEventListener("click", sleep); meet.addEventListener("click", meeting); //These functions are for the respective tip buttons function physical(){ alert("How does your body feel? Do you feel sick? Are you sore? Do you feel injured? Is your energy level normal?"); } function academic(){ alert("How are your classes going? What is your workload like? Are you falling behind? Are you ahead? Do you have a lot of exams/papers/projects?"); } function perform(){ alert("How do you feel about your current performance? Are you satisfied with your role on the team? Do you feel confident? How is your mindset? How is your self talk during games and practices?"); } function relation(){ alert("How are your relationships with your friends, family, roommates, significant others, and teammates? Are you struggling to maintain any of these relationships? Are you facing any challenges in a certain relationships?"); } function sleep(){ alert("Select the closest number to the amount of sleep you got last night."); } function meeting(){ alert("An urgent meeting will have your coach contacting you as soon as possible. A normal meeting will have your coach contacting you within the week."); } //the following puts the slider value on screen var slider = document.getElementById("sleep"); //this is the slider itself var output = document.getElementById("hours"); //this is the value that will be outputted to the screen output.innerHTML = slider.value; slider.oninput = function() { //when the slider takes input it calls this function. output.innerHTML = this.value; //it takes the current value and puts it on screen } function radioButtonCheck(theCategory) { var Checked = false; for (i = 1; i <= 5; i++){ if (document.getElementById(theCategory+i).checked) Checked = true; } return Checked; } function check() { //alert("inside check"); ID = document.getElementById("id"); ID = ID.value.trim(); if (ID.length != 6) { alert("ID must have six characters."); isOK = false; } isOK = true; if (radioButtonCheck("phys") == false) { isOK = false; } if (radioButtonCheck("acad") == false) isOK = false; if (radioButtonCheck("perf") == false) isOK = false; if (radioButtonCheck("rela") == false) isOK = false; if ( !(document.getElementById("urgent").checked || document.getElementById("yes").checked || document.getElementById("no").checked ) ) isOK = false; if (isOK == false) alert("please complete the form"); //else // alert("good to go!"); //return false; // CHANGE TO BELOW ONCE COMPLETE return isOK; }