Skip to content

Commit

Permalink
Added all JavaScript
Browse files Browse the repository at this point in the history
  • Loading branch information
em1lylauren authored Jun 20, 2024
1 parent 3339c36 commit 5d55786
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 0 deletions.
49 changes: 49 additions & 0 deletions JAVASCRIPT/carousel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Emily Hartz-Kuzmicz
job346
11350337
CMPT281
*/

let slideIndex = 1;
displaySlides(slideIndex);

/*
Changes the image based on which (< >) button is pressed.
Parameters:
n: An integer to add to slideIndex, then pass to
displaySlides to show the new image.
*/
function changeSlides(n) {
displaySlides(slideIndex += n);
}

/*
Displays a single carousel image.
Parameters:
n: An integer index value to access the image in the
array of carousel images.
*/
function displaySlides(n) {
let i;
let slides = document.getElementsByClassName("CarouselImage");

//If the index is greater than the array length
if (n > slides.length) {
slideIndex = 1;

//If the index is smaller than the smallest array index
} else if (n < 1) {
slideIndex = slides.length;
}

//Sets all images to display=none
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}

//Shows a single image
slides[slideIndex-1].style.display = "initial";
}
73 changes: 73 additions & 0 deletions JAVASCRIPT/submitbooking.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
Emily Hartz-Kuzmicz
job346
11350337
CMPT281
*/

/*
Submits the form on the "Booking" Page.
*/
function formSubmit() {
let loginForm = document.getElementById("Form");

loginForm.addEventListener("submit", (e) => {
e.preventDefault();

//Take in all data from form
let fname = document.getElementById("fname");
let lname = document.getElementById("lname");
let phonenum = document.getElementById("phonenum");
let email = document.getElementById("email");
let returning_patient, contact_method;

//Check which radio button is selected for returning patient
if (document.getElementById("returning_patientyes").checked) {
returning_patient = "yes";
} else {
returning_patient = "no";
}

//Check which radio button is selected for contact method
if (document.getElementById("contact_methodphone").checked) {
contact_method = "phone";
} else {
contact_method = "email";
}

let day = document.getElementById("day");
let time = document.getElementById("time");
let message = document.getElementById("message");

//If any of the required field values are empty
if (fname.value == "" || lname.value == "" || phonenum.value == "" || email.value == "" || message.value == "") {
alert("The following values cannot be empty: First Name, Last Name, Phone Number, Email.");

} else {
alert("Your appointment request has been successfully submitted!");

//Log the given data to the console
console.log(
`First Name: ${fname.value}\nLast Name: ${lname.value}\nPhone Number: ${phonenum.value}\nEmail: ${email.value}\n`
);

console.log(
`Returning Patient: ${returning_patient}\nContact Method: ${contact_method}\n`
);

console.log(
`Requested Day: ${day.value}\nRequested Time: ${time.value}\nMessage: ${message.value}\n`
);

//Set all values back to empty
fname.value = "";
lname.value = "";
phonenum.value = "";
email.value = "";

day.value = "monday";
time.value = "9";
message.value = "";
}
});
}
46 changes: 46 additions & 0 deletions JAVASCRIPT/submitcontact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
Emily Hartz-Kuzmicz
job346
11350337
CMPT281
*/

/*
Submits the form on the "Contact Us" Page.
*/
function formSubmit() {
let loginForm = document.getElementById("Form");

loginForm.addEventListener("submit", (e) => {
e.preventDefault();

//Take in all data from form
let fname = document.getElementById("fname");
let lname = document.getElementById("lname");
let phonenum = document.getElementById("phonenum");
let email = document.getElementById("email");
let subject = document.getElementById("subject");
let message = document.getElementById("message");

//If any of the required field values are empty
if (fname.value == "" || lname.value == "" || phonenum.value == "" || email.value == "" || subject.value == "" || message.value == "") {
alert("The following values cannot be empty: First Name, Last Name, Phone Number, Email, Subject, Message.");

} else {
alert("Your contact request has been successfully submitted!");

//Log the given data to the console
console.log(
`First Name: ${fname.value}\nLast Name: ${lname.value}\nPhone Number: ${phonenum.value}\nEmail: ${email.value}\nSubject: ${subject.value}\nMessage: ${message.value}`
);

//Set all values back to empty
fname.value = "";
lname.value = "";
phonenum.value = "";
email.value = "";
subject.value = "";
message.value = "";
}
});
}

0 comments on commit 5d55786

Please sign in to comment.