I am making an order form where the user enters an
item number, description, quantity and price. The form should calculate the extended price,
subtotal , sales tax and grand total. I defined the functions but dont understand how to call
them and where in the code to call them. Any help would be greatly appreciated. I am
attaching the file that I have completed this far.
Thanks,
Kady
<HTML>
<HEAD>
<TITLE>
Kates Aromatherapy Form Prooject 3
</TITLE>
<script LANGUAGE="javascript">
function ExtendedPrice1 (qty1, price1)
{
return (qty1*price1)
}
function ExtendedPrice2 (qty2, price2)
{
return (qty2*price2)
}
function ExtendedPrice3 (qty3, price3)
{
return (qty3*price3)
}
function ExtendedPrice4 (qty4, price4)
{
return (qty4*price4)
}
function SubTotal (extprice1, extprice2, extprice3, extprice4)
{
return (extprice1 + extprice2 + extprice3 + extprice4)
}
function SalesTax (subtot)
{
var tax = 0.06;
return (tax * subtot)
}
function Shipping (subtot, tax)
{
var shipexpense = 5.95
return (subtot + salestax + shipexpense)
}
function GrandTotal (subtot, ship, salestax)
{
return (subtot + ship + salestax)
}
</script>
</HEAD>
<BODY bgcolor="#990000">
<STYLE>
FORM { background:#CC9900; border: #663300 double 8px;
}
</STYLE>
<CENTER><B><FONT SIZE= 5><FONT FACE="Times New Roman">KATES AROMATHERAPY ORDER CATALOG, INC.</b>
<br>
2444 Homeworth Rd.
<br>
Alliance, OH 44601
<br>
330 525-7939
</font>
</CENTER>
<br>
<hr width ="75%" Align=center size ="5" color="#CC9900">
<br>
<FONT SIZE=4> <FONT FACE= "Times New Roman">
Please enter the following information to process your order.
</FONT>
<br>
<PRE>
<FONT SIZE=3> <FONT FACE= "Times New Roman">
<FORM>
<b>SOLD TO: SHIP TO:</b>
<br>
Company Name: <INPUT type="text" name="CoName1" Size=30> Company Name: <INPUT type="text" name="CoName2" Size=30>
<br>
Address: <INPUT type="text" name="AdName1" Size=30> Address: <INPUT type="text" name="AdName2"Size=30>
<br>
City, State, Zip: <INPUT type="text" name="CSZName1"Size=30> City, State, Zip: <INPUT type="text" name="CSZName2"Size=30>
<br>
Contact Person: <INPUT type="text" name="CPName1"Size=30> Contact Person: <INPUT type="text" name="CPName2"Size=30>
<br>
Phone Number: <INPUT type="text" name="PhNum1"Size=30> Phone Number: <INPUT type="text" name="PhNum2"Size=30>
<b>INVOICE TO:</b>
Company Name: <INPUT type="text" name="CoName2" Size=30>
Address: <INPUT type="text" name="AdName2"Size=30>
City, State, Zip: <INPUT type="text" name="CSZName2"Size=30>
Contact Person: <INPUT type="text" name="CPName2"Size=30>
Phone Number: <INPUT type="text" name="PhNum2"Size=30>
</FONT>
<FONT SIZE=4><FONT FACE="Times New Roman">
Enter the items you wish to purchase.
</FONT>
<FONT SIZE=3><FONT FACE="Times New Roman">
Item Number Description QTY Price Ext Price
<INPUT type="text" name="item1" size=12> <INPUT type="text" name="descript1" size=30> <INPUT type="text" name="qty1" size=05> <INPUT type="text" name="price1" size=05> <INPUT type="text" name="extprice1" size=12 OnChange="ExtendedPrice1 ()">
<INPUT type="text" name="item2" size=12> <INPUT type="text" name="descript2" size=30> <INPUT type="text" name="qty2" size=05> <INPUT type="text" name="price2" size=05> <INPUT type="text" name="extprice2" size=12 OnChange="ExtendedPrice2 ()">
<INPUT type="text" name="item3" size=12> <INPUT type="text" name="descript3" size=30> <INPUT type="text" name="qty3" size=05> <INPUT type="text" name="price3" size=05> <INPUT type="text" name="extprice3" size=12 OnChange="ExtendedPrice3 ()">
<INPUT type="text" name="item4" size=12> <INPUT type="text" name="descript4" size=30> <INPUT type="text" name="qty4" size=05> <INPUT type="text" name="price4" size=05> <INPUT type="text" name="extprice4" size=12 OnChange="ExtendedPrice4 ()">
SubTotal <INPUT type="text" name="subtot" size=12 OnChange="SubTotal ()">
Sales Tax <INPUT type="text" name="salestax" size=12 OnChange="SalesTax ()">
Shipping & Handling <INPUT type="text" name="ship" size=12 OnChange="Shipping ()">
Grand Total <INPUT type="text" name="grandtot" size=12 OnChange="GrandTotal ()">
</FORM>
</PRE>
</BODY>
</HTML>