-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresponse.js
More file actions
26 lines (25 loc) · 1.04 KB
/
response.js
File metadata and controls
26 lines (25 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
window.onload = function () {
showSummary();
}
//Adds the cost of each item plus delivery and shows the customer the total, also called on the submit button incase they make changes.
function price() {
var itemPrice = document.getElementsByName("item");
var total = 0.0;
for (var i = 0; i < itemPrice.length; i++) {
if (itemPrice[i].checked) {
total = total + parseFloat(itemPrice[i].value);
}
}
total = total + parseFloat(document.getElementById("delivery").value);
document.getElementById("totalCost").value = total;
}
//Gets info from the URL parameters and prints them as a summary.
function showSummary() {
let params = new URLSearchParams(location.search);
document.getElementById("summary").innerHTML =
"First name: " + params.get("fName") +
"<br />Last name: " + params.get("lName") +
"<br />Total cost: $" + params.get("totalCost") +
"<br />Email address: " + params.get("email") +
"<br />Comment: " + params.get("comments");
}