Question
Will you help me with this hands on project? There is something wrong with my code, but I don't know what it is. JavaScript Web
Will you help me with this hands on project? There is something wrong with my code, but I don't know what it is.
JavaScript Web Warrior Series (6th Edition) Hands on Project 7-5
"use strict";
var delivInfo = {};
var delivSummary = document.getElementById("deliverTo");
function processDeliveryInfo() {
var prop;
delivInfo.name = document.getElementById("nameinput").value;
delivInfo.addr = document.getElementById("addrinput").value;
delivInfo.city = document.getElementById("cityinput").value;
delivInfo.email = document.getElementById("emailinput").value;
delivInfo.phone = document.getElementById("phoneinput").value;
for (prop in delivInfo) {
delivSummary.innerHTML += "
" + delivInfo[prop] + "
";}
};
function previewOrder() {
processDeliveryInfo();
processFood();
document.getElementById("deliverTo").style.display = "block";
document.getElementsByTagName("section")[0].style.display = "block";
};
function createEventListener() {
var previewButton = document.getElementById("previewBtn");
if (previewButton.addEventListener) {
previewButton.addEventListener("click", previewOrder, false);
} else if (previewButton.attachEvent) {
previewButton.attachEvent("onclick", previewOrder);
}
};
if (window.addEventListener) {
window.addEventListener("load", createEventListener, false);
} else if (window.attachEvent) {
window.attachEvent("onload", createEventListener)
}
// Hands-On Project 7-5: order and food processing
var foodInfo = {};
var foodSummary = document.getElementById("order");
function processFood() {
var prop;
var crustOpt = document.getElementsByName("crust");
var toppings = 0;
var toppingBoxes = document.getElementsByName("toppings");
var instr = document.getElementById("instructions");
if (crustOpt[0].checked) {
foodInfo.crust = crustOpt[0].value;
} else {
foodInfo.crust = crustOpt[1].value;
}
foodInfo.size = document.getElementById("size").value;
for (var j = 0; j < toppingBoxes.length; j++) {
if (toppingBoxes[j].checked) {
toppings += 1;
foodInfo["topping" + toppings] = toppingBoxes[j];
}
}
if (instr !== "") {
foodInfo.instructions = instr.value;
}
foodSummary.innerHTML += "
Crust: " + foodInfo.crust + "
";foodSummary.innerHTML += "
Size: " + foodInfo.size + "
";foodSummary.innerHTML += "
Topping(s): " + "
"foodSummary.innerHTML += "
- ";
- " + foodInfo["topping" + i] + " ";
for (var i = 1; i < 6; i++) {
if (foodInfo["topping" + i]) {
foodSummary.innerHTML += "
}
}
foodSummary.innerHTML += "
foodSummary.innerHTML += "
Instructions: " + foodInfo.instructions;
document.getElementById("order").style.display = "block";
};
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started