I copied out the example, it more or less works except the processor isn't added to the total. Can anybody see what I have missed?
<html>
<head>
<script language = JavaScript>
var CompItems = new Array();
CompItems[100] = 1000;
CompItems[101] = 1250;
CompItems[102] = 1500;
CompItems[200] = 35;
CompItems[201] = 65;
CompItems[202] = 95;
CompItems[300] = 50;
CompItems[301] = 75;
CompItems[302] = 100;
CompItems[400] = 10;
CompItems[401] = 15;
CompItems[402] = 25;
function updateOrderDetails()
{
var total = 0;
var orderDetails = "";
var formElement;
formElement =
document.form1.cboProcessor[document.form1.cboProcessor.selectedIndex];
total = parseFloat (CompItems[formElement.value]);
orderDetails = "Processor : " + formElement.text;
orderDetails = orderDetails + " $" + CompItems[formElement.value] + "\n";
formElement =
document.form1.cboHardDrive[document.form1.cboHardDrive.selectedIndex];
total = parseFloat (CompItems[formElement.value]);
orderDetails = "Hard Drive : " + formElement.text;
orderDetails = orderDetails + " $" + CompItems[formElement.value] + "\n";
formElement = document.form1.chkCDROM
if (formElement.checked == true)
{
orderDetails = orderDetails + "CD-ROM : $" +
CompItems[formElement.value] + "\n";
total = total + parseFloat(CompItems[formElement.value]);
}
formElement = document.form1.chkDVD
if (formElement.checked == true)
{
orderDetails = orderDetails + "DVD-ROM : $" +
CompItems[formElement.value] + "\n";
total = total + parseFloat(CompItems[formElement.value]);
}
formElement = document.form1.chkScanner
if (formElement.checked == true)
{
orderDetails = orderDetails + "Scanner : $" +
CompItems[formElement.value] + "\n";
total = total + parseFloat(CompItems[formElement.value]);
}
formElement = document.form1.radCase
if (formElement[0].checked == true)
{
orderDetails = orderDetails + "Desktop Case : $" +
CompItems[formElement[0].value] + "\n";
total = total + parseFloat(CompItems[formElement[0].value]);
}
else if (formElement[1].checked == true)
{
orderDetails = orderDetails + "Mini Tower Case : $" +
CompItems[formElement[1].value] + "\n";
total = total + parseFloat(CompItems[formElement[1].value]);
}
else
{
orderDetails = orderDetails + "Full Tower Case : $" +
CompItems[formElement[2].value] + "\n";
total = total + parseFloat(CompItems[formElement[2].value]);
}
orderDetails = orderDetails + "\n\nTotal Order Cost is $" + total;
document.form1.txtOrder.value = orderDetails;
}
</script>
</head>
<body>
<form name=form1>
<table>
<TR>
<TD width = 300>
Processor
<br>
<select name = cboProcessor >
<option value = 100 >MegaPro 1ghz</option>
<option value = 101 >MegaPro 1.2ghz</option>
<option value = 102 >MegaPro 1.5ghz</option>
</select>
<br><br>
Hard drive
<br>
<select name = cboHardDrive >
<option value = 200>30gb</option>
<option value = 201>40gb</option>
<option value = 202>60gb</option>
</select>
<br><br>
CD-ROM
<input type = "checkbox" name = chkCDROM value="300" >
<br>
DVD-ROM
<input type = "checkbox" name = chkDVD value="301" >
<br>
Scanner
<input type = "checkbox" name = chkScanner value="302" >
<br>
Desktop Case
<input type = "radio" name = radCase value="400" >
<br>
Mini Tower
<input type = "radio" name = radCase value="401" >
<br>
Full Tower
<input type = "radio" name = radCase value="402" >
<br>
<P>
<input type = "button" value = "Update" name=butUpdate onclick="updateOrderDetails()">
</P>
</TD>
<TD>
<textarea rows = 20 cols = 35 id=txtOrder name=txtOrder>
|