HTML and CSS Reference
In-Depth Information
To Create the monthlyPmt() Function
The following step enters the monthlyPmt() user-defined function to calculate the monthly payment on a
auto loan.
1
values in line 61 are
passed to monthlyPmt()
function
Click the beginning of
line 67 and press the
e n t e r key once.
yearly interest
rate converted to
monthly rate
Position the insertion
point on the blank
line 67 just created.
Enter the JavaScript
number of
years converted
to number of
payments
toFixed() method
used to strip off
extra decimal
values
code shown in
Table 10-18 to write
the code to calculate
the monthly payment
and then press the
e n t e r key once
(Figure 10-25).
Math.pow() method
used in expression to
calculate exponential
values
Figure 10-25
To Save an HTML File and Test a Web Page
Now that the monthly payment can be calculated, this is a good place to test the
Web page. You should not continue to the next section until this code is working properly.
The following steps save the HTML file and test the Web page.
1
With the USB drive plugged into the computer, click File on the menu bar, and then
click Save.
2
Click the browser button on the taskbar.
3
Click the Refresh button next to the Address box.
4
Click the Reset button on the form.
5
If necessary, click the Sales Price text field to place the insertion point in the text field.
6
Type 174500 in the Sales Price text field and then press the t a b key.
7
Type 51000 in the Down Payment text field and then press the t a b key. If there are
no errors, the Loan Amount of 123500 is calculated and displays in the Loan Amount
text field.
8
Type 4.5 in the Interest Rate (e.g. 5.9) text field and then press the t a b key.
9
Select 30 in the Number of Years drop-down menu field and then click the Calculate
button (Figure 10-26 on the next page).
What if my result was slightly different? Did I do something wrong?
If your result is only a few cents different, it is probably just a difference in the math proces-
sor on your computer. If the value is hundreds or even thousands of dollars off, check your
formula code on lines 68 through 70.

Search WWH ::

Custom Search