Java Reference
In-Depth Information
So:
alert(document.form1.txtCalcBox.value);
is the same as:
alert(calcBox.value);
In the remaining part of the function you do a sanity check—if what the user has entered is a
number (that is, it is not NotANumber ) and the text box does contain a value, you use the Fahrenheit‐
to‐centigrade conversion function you saw in Chapter 2 to do the conversion, the results of which
are used to set the text box's value.
exercise 2 Question
Create a user interface that allows users to pick the computer system of their dreams, similar in
principle to the e‐commerce sites selling computers over the Internet. For example, they could
be given a choice of processor type, speed, memory, and hard drive size, and the option to add
additional components like a DVD‐ROM drive, a sound card, and so on. As the users change their
selections, the price of the system should update automatically and notify them of the cost of the
system as they specified it, either by using an alert box or by updating the contents of a text box.
exercise 2 Solution
<!DOCTYPE html>
<html lang="en">
<head>
<title>Chapter 11: Question 2</title>
</head>
<body>
<form action="" name="form1">
<p>
Choose the components you want included on your computer
</p>
<p>
<label for="cboProcessor">Processor</label>
<select name="cboProcessor" id="cboProcessor">
<option value="100">Dual-core 2GHz</option>
<option value="101">Quad-core 2.4GHz</option>
<option value="102">Eight-core 3GHz</option>
</select>
</p>
<p>
<label for="cboSsd">Solid-state Drive</label>
<select name="cboSsd" id="cboSsd">
<option value="200">250GB</option>
<option value="201">512GB</option>
<option value="202">1TB</option>
</select>
</p>
Search WWH ::




Custom Search