Question
4.1 handson in the following javascript code follow the directions on the picture below /* JavaScript 6th Edition * Chapter 4 * 4.1 handson *
4.1 handson in the following javascript code follow the directions on the picture below
/* JavaScript 6th Edition * Chapter 4 * 4.1 handson
* Tuba Farm Equipment * Variables and functions * Author: * Date:
* Filename: tuba.js */
/* global variables tracking status of each form section */ var acresComplete = true; var cropsComplete = true; var monthsComplete = true; ar fuelComplete = true;
/* global variables referencing sidebar h2 and p elements */ var messageHeadElement = document.getElementById("messageHead"); var messageElement = document.getElementById("message");
/* global variables referencing fieldset elements */ var acresFieldset = document.getElementsByTagName("fieldset")[0]; var cropsFieldset = document.getElementsByTagName("fieldset")[1]; var monthsFieldset document.getElementsByTagName("fieldset")[2]; var fuelFieldset = document.getElementsByTagName("fieldset)[3];
/* global variables referencing text input elements */ var monthsBox = document.forms[0].months; var acresBox = document.forms[0].acres;
/* verify acres text box entry is a positive number */ function verifyAcres) { testFormCompleteness(); }
/* verify at least one crops checkbox is checked */ function verifyCrops() { testFormCompleteness(); }
/* verify months text box entry is between 1 and 12 */ function verifyMonths() { testFormCompleteness(); }
/* verify that a fuel option button is selected */ function verifyFuel() { testFormCompleteness(); }
/* check if all four form sections are completed */ function testFormCompleteness() { if (acresComplete && cropsComplete && monthsComplete && fuelComplete) { createRecommendation(); } }
/* generate tractor recommendation based on user selections */ function createRecommendation() { if (acresBox.value >= 5000) { // 5000 acres or less, no crop test needed if (monthsBox.value
/* create event listeners for all input elements */ function createEventListeners() { acresBox.value = ""; // clear acres text box on page load monthsBox.value = ""; // clear months text box on page load
if (acresBox.addEventListener) { acresBox.addEventListener("input", verifyAcres, false); } else if (acresBox.attachEvent) { acresBox.attachEvent("onchange", verifyAcres); } var cropsBox; for (var i = 0; i
var fuelBox; for (var i = 0; i
/* create event listeners when page finishes loading */ if (window.addEventListener) { window.addEventListener("load", createEventListeners, false); } else if (window.attachEvent) { window.attachEvent("onload", createEventListeners); }
Scroll down to the verifyCrops () function, and then delete the line testFormCompleteness (); so the command block is empty. 5. Below the try statement but before the closing of the verifyCrops () function, add the following catch () statement: Enter the following try statement within the command block of the verifyCrops () function: 1 catch (message) { cropaComplete or false ; I try { messageieadElement.innerHTML = *; I remove any former for (var i = 0; iStep 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