Java Reference
In-Depth Information
The fi rst page is the frameset page, which the browser loads fi rst.
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Chapter 8: Question 1 Answer</title>
</head>
<frameset cols=”55%,*”>
<frame src=”ch8_q1_picksystem.htm” name=”pickSystem”>
<frame src=”about:blank” name=”systemSummary”>
</frameset>
</html>
Save this as ch8_q1_frameset.htm.
Finally, you come to the page loaded into the left frame; it allows the user to choose their computer
system and its components. This is very similar to the solution to Question 2 in the previous chapter, so
this example shows only what changed. All the changes are within the updateOrderDetails() func-
tion, and they're highlighted in the following code:
function updateOrderDetails()
{
var total = 0;
var orderDetails = “”;
var formElement;
var theForm = document.form1;
formElement = theForm.cboProcessor[theForm.cboProcessor.selectedIndex];
total = parseFloat(compItems[formElement.value]);
orderDetails = “Processor : “ + formElement.text;
orderDetails = orderDetails + “ $” + compItems[formElement.value] + “<br />”;
formElement = theForm.cboHardDrive[theForm.cboHardDrive.selectedIndex];
total = total + parseFloat(compItems[formElement.value]);
orderDetails = orderDetails + “Hard Drive : “ + formElement.text;
orderDetails = orderDetails + “ $” + compItems[formElement.value] + “<br />”;
formElement = theForm.chkCDROM;
if (formElement.checked == true)
{
orderDetails = orderDetails + “CD-ROM : $”
+ compItems[formElement.value] + “<br />”;
total = total + parseFloat(compItems[formElement.value]);
}
formElement = theForm.chkDVD;
if (formElement.checked == true)
{
orderDetails = orderDetails + “DVD-ROM : $”
+ compItems[formElement.value] + “<br />”;
total = total + parseFloat(compItems[formElement.value]);
}
formElement = theForm.chkScanner;
Search WWH ::




Custom Search