From the course: JavaScript: Web Form Programming

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Form programming

Solution: Form programming

From the course: JavaScript: Web Form Programming

Start my 1-month free trial

Solution: Form programming

(upbeat music) - All right, let's take a look at how I chose to solve this particular programming challenge, and remember, it's not important that your solution matches mine exactly, there are almost always multiple ways to solve a given programming problem, and the point here is to examine a particular solution, and learn from it. So this challenge required us to listen for form events to update a running total for a pizza order. So let's take a look at the function that updates the total first, and then we'll examine the various events that the forum listens too. So, we scroll down here in my code, you'll see that I created a function named update form total that examines each form field and uses the information in that field to calculate the cost of the pizza order. So the function starts by getting a reference to the output element in the forum, and then initializes the bill to zero. Then my update form total…

Contents