Question: You are provided at the assignment site the HTML document prob2.html with a large gap. This document references the JavaScript file prob2.js (which you write)
You are provided at the assignment site the HTML document prob2.html with a large gap. This document references the JavaScript file prob2.js (which you write) and calls function go() when the body finishes loading. File prob2.js contains only the definition of go(). The following is file prob2.html with the contents of the form element removed. The initial rendering is shown on the right.

The textbox for the first name has name "fname", and that for the last name has name "lname". Both the textboxes are twelve character spaces wide. When the button is clicked, function go() (defined in prob2.html) is called. The four checkboxes, all with name "food", are inside a fieldset, with the legend shown. The value of the value attribute of each item is its price (dollars understood): 1.10 (for a quart of milk), 2.31 (for a dozen eggs), 1.57 (for a head of lettuce), and 4.90 (for 5 lbs. of potatoes). Each checkbox is associated with a label element, which can be clicked for the same effect as clicking the control itself. Function go() gets a reference, tot, to the div element with id "total". It sums up the values (converted to floating-point numbers) of those checkboxes that are checked and assigns this sum to the innerHTML property of tot. This function also gets a reference, name, to the div element with id "name". It assigns to the innerHTML property of name the concatenation of the first and last names (separated by a space). The screenshot at right shows the result after clicking the button when Albert was entered for the first and Esterline for the last name, and the second and fourth checkboxes were checked.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
