HTML and CSS Reference
To Enter an onClick Event Handler to Call the CalcLoanAmt() Function
The last step in validating the mortgage loan payment calculator is to add an event handler to invoke the
CalcLoanAmt() function when the user clicks the Calculate button. After entering all the data in the form, a user
clicks the Calculate button, which triggers the CalcLoanAmt() function to validate the interest rate and number
of years data entered in the form. The following step enters the onClick event handler to call the CalcLoanAmt()
onClick event handler
function when user clicks
Scroll down to the
HTML code for the
form and then click
line 174 right after
the closing quote
in “Calculate” and
before the right-
most /> bracket.
do not press
the e n t e r key
s p a c e b a r
to add the event handler to the Calculate button, but do not press
the e n t e r key (Figure 10-22).
To Save an HTML File and Test a Web Page
and tested in a browser. The CalcLoanAmt() function will validate the text field entries, but
will not yet calculate the monthly payment. The following steps save the HTML file and
test the Web page. Do not continue until this code is working properly.
With the USB drive plugged into your computer, click File on the menu bar, and then
Click the browser button on the taskbar.
Click the Refresh button on the Address bar.
When the Web page is displayed, click the Sales Price text field.
Enter the test data set 1, as shown in Table 10-16 on the next page, pressing the t a b key
to move to the next text field.
When an error message appears, click the OK button, and enter a valid number for the
When you have entered the test data set 1, click the Calculate button at the bottom of
After completing a set of data, click the Reset button at the bottom of the form.
Repeat Steps 5 through 8, using test data sets 2, 3, and 4, as shown in Table 10-16, and
respond to any error messages. Figure 10-23 on the next page shows the fourth data set
with the error message.