Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 += "

    ";

    for (var i = 1; i < 6; i++) {

    if (foodInfo["topping" + i]) {

    foodSummary.innerHTML += "

  • " + foodInfo["topping" + i] + "
  • ";

    }

    }

    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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

administer a survey to an appropriate sample of respondents;

Answered: 1 week ago

Question

=+10. How are inflation and unemployment related in the short run?

Answered: 1 week ago

Question

=+8. Why is productivity important?

Answered: 1 week ago