<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
<title>Classroom Connection</title>
<script language="javascript" type="text/javascript">
function calcTotal(productList) {
var bulletinBoard = Number(productList.box1.value);
var stickers = Number(productList.box2.value);
var cutouts = Number(productList.box3.value);
var trimmer = Number(productList.box4.value);
var resourceBooks = Number(productList.box5.value);
productList.total.value = 12 * bulletinBoard + 1 * stickers + 6 * cutouts + 3 * trimmer + 20 * resourceBooks;
}
</script>
</head>
<body bgcolor="white">
<p><center><font face="brush script mt" font size="250" color="#306754">Classroom Connection</font></center></p>
<h1>Customer Order Form</h1>
<form action="classroomconnection.asp">
<!--Customer Information-->
First Name:<input type="text" name="FirstName"><br>
Last Name:<input type="text" name="LastName"><br>
Street Address:<input type="text" name="StreetAddress"><br>
City:<input type="text" name="City"><br>
Zip Code:<input type="text" name="ZipCode"><br>
Phone Number((123)-555-1234):<input type="text" name="PhoneNumber"><br>
<!--Add Products Here-->
<h2>Products</h2>
<h3>Choose Your Items</h3>
<!--To display products and calculate their total-->
<script type="text/javascript" src="ProductDesc.js">
/* <![CDATA[ */
/* ]]> */
</script>
<!--added radio buttons-->
<form name="productsList" action="" method="get">
<p>Click the buttons for a description of each product.</p>
<img src="BB1.jpeg" width="80" height="80" alt="Visual Formatting Element" />
<input type="radio" name="products" onclick="window.alert(bulletinBoards)">
<p>Bulletin Boards</p>
<input type="text" size="3" maxlength="3" name="box1"><br>
<img src="CDstickers1.jpeg" width="80" height="80" alt="Visual Formatting Element" />
<input type="radio" name="products" onclick="window.alert(stickers)">
<p>Stickers</p>
<input type="text" size="3" maxlength="3" name="box2"><br>
<img src="CDCutouts1.jpeg" width="80" height="80" alt="Visual Formatting Element" />
<input type="radio" name="products" onclick="window.alert(cutouts)">
<p>Cutouts</p>
<input type="text" size="3" maxlength="3" name="box3"><br>
<img src="CDTrimmer.jpeg" width="80" height="80" alt="Visual Formatting Element" />
<input type="radio" name="products" onclick="window.alert(trimmers)">
<p>Trimmer</p>
<input type="text" size="3" maxlength="3" name="box4"><br>
<img src="CDResourceBooks1.jpeg" width="80" height="80" name="box4" alt="Visual Formatting Element" />
<input type="radio" name="products" onclick="window.alert(resourceBooks)">
<p>Resource Books</p>
<input type="text" size="3" maxlength="3" name="box5"><br>
<input type="button" onClick="calcTotal(this.form)" value="Calculate Total">
<input type="text" size="3" maxlength="3" name="total"><br>
</form>
</form>
</body>
</html>
Bear Bibeault wrote:Firstly, while is a poor choice. A while loop is best when the iteration is unbounded. In this case, you have an array with a finite length; what would be a better way?
Secondly, I assume you want to accumulate quantities. Review what ++ does and check if it's the right approach.
Then, never omit braces on compound statements. it's a poor practice than can cause issues when you least expect it.
And, why two arrays? What is the purpose of the second array?
Bear Bibeault wrote:Yes, a for loop wold be better.
If your instructor wants the values in separate arrays, you don't want to use the object approach that was earlier recommend. You should let us know about these types of artificial restrictions at the beginning.
Bear Bibeault wrote:The index of the for loop can be used to index into any number of arrays.
Bear Bibeault wrote:Suggestion: arrays are plural. So perhaps the names should be as well?
Bear Bibeault wrote: I'm not sure how suggesting that you use plural names for plural items is cryptic. Use prices when declaring an array of prices. Use quantities when declaring an array of quantities. Pretty straightforward.
With regards to the browser debugger, it's a necessary tool that you need to learn to use. It will show you, and tell you pretty explicitly, what's wrong with line 16.
But yes, the aim of the site is to help you along, not just give out the answers.
But you're really close! Don't give up now.
Don't get me started about those stupid light bulbs. |