JavaScript

Moderators: None (Apply to moderate this forum)
Number of threads: 2058
Number of posts: 5158

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Calling a function Posted by kady63 on 19 Oct 2002 at 6:29 PM
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>

Report
Re: Calling a function Posted by ayanroy on 20 Oct 2002 at 6:43 PM
u can ,make a button which will calculate the price,salestex etc. and call the functions onclick.

or u can call the function onfocus or onblur in the textfield



: 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>
:
: 2444 Homeworth Rd.
:
: Alliance, OH 44601
:
: 330 525-7939
: </font>
: </CENTER>
:
: <hr width ="75%" Align=center size ="5" color="#CC9900">
:
: <FONT SIZE=4> <FONT FACE= "Times New Roman">
: Please enter the following information to process your order.
: </FONT>
:
:
: <PRE>
: <FONT SIZE=3> <FONT FACE= "Times New Roman">
: <FORM>
: <b>SOLD TO: SHIP TO:</b>
:
: Company Name: <INPUT type="text" name="CoName1" Size=30> Company Name: <INPUT type="text" name="CoName2" Size=30>
:
: Address: <INPUT type="text" name="AdName1" Size=30> Address: <INPUT type="text" name="AdName2"Size=30>
:
: City, State, Zip: <INPUT type="text" name="CSZName1"Size=30> City, State, Zip: <INPUT type="text" name="CSZName2"Size=30>
:
: Contact Person: <INPUT type="text" name="CPName1"Size=30> Contact Person: <INPUT type="text" name="CPName2"Size=30>
:
: 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>
:
:



Report
Thank You very much Ayanroy Posted by kady63 on 21 Oct 2002 at 4:18 AM
:Thanks again and one quick question. Do I have my functions defined correctly?

u can ,make a button which will calculate the price,salestex etc. and call the functions onclick.
:
: or u can call the function onfocus or onblur in the textfield
:
:
:
: : 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>
: :
: : 2444 Homeworth Rd.
: :
: : Alliance, OH 44601
: :
: : 330 525-7939
: : </font>
: : </CENTER>
: :
: : <hr width ="75%" Align=center size ="5" color="#CC9900">
: :
: : <FONT SIZE=4> <FONT FACE= "Times New Roman">
: : Please enter the following information to process your order.
: : </FONT>
: :
: :
: : <PRE>
: : <FONT SIZE=3> <FONT FACE= "Times New Roman">
: : <FORM>
: : <b>SOLD TO: SHIP TO:</b>
: :
: : Company Name: <INPUT type="text" name="CoName1" Size=30> Company Name: <INPUT type="text" name="CoName2" Size=30>
: :
: : Address: <INPUT type="text" name="AdName1" Size=30> Address: <INPUT type="text" name="AdName2"Size=30>
: :
: : City, State, Zip: <INPUT type="text" name="CSZName1"Size=30> City, State, Zip: <INPUT type="text" name="CSZName2"Size=30>
: :
: : Contact Person: <INPUT type="text" name="CPName1"Size=30> Contact Person: <INPUT type="text" name="CPName2"Size=30>
: :
: : 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>
: :
: :
:
:
:
:

Report
Thank You very much Ayanroy Posted by kady63 on 21 Oct 2002 at 4:18 AM
:Thanks again and one quick question. Do I have my functions defined correctly?

u can ,make a button which will calculate the price,salestex etc. and call the functions onclick.
:
: or u can call the function onfocus or onblur in the textfield
:
:
:
: : 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>
: :
: : 2444 Homeworth Rd.
: :
: : Alliance, OH 44601
: :
: : 330 525-7939
: : </font>
: : </CENTER>
: :
: : <hr width ="75%" Align=center size ="5" color="#CC9900">
: :
: : <FONT SIZE=4> <FONT FACE= "Times New Roman">
: : Please enter the following information to process your order.
: : </FONT>
: :
: :
: : <PRE>
: : <FONT SIZE=3> <FONT FACE= "Times New Roman">
: : <FORM>
: : <b>SOLD TO: SHIP TO:</b>
: :
: : Company Name: <INPUT type="text" name="CoName1" Size=30> Company Name: <INPUT type="text" name="CoName2" Size=30>
: :
: : Address: <INPUT type="text" name="AdName1" Size=30> Address: <INPUT type="text" name="AdName2"Size=30>
: :
: : City, State, Zip: <INPUT type="text" name="CSZName1"Size=30> City, State, Zip: <INPUT type="text" name="CSZName2"Size=30>
: :
: : Contact Person: <INPUT type="text" name="CPName1"Size=30> Contact Person: <INPUT type="text" name="CPName2"Size=30>
: :
: : 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>
: :
: :
:
:
:
:

Report
Re: Thank You very much Ayanroy Posted by ayanroy on 21 Oct 2002 at 12:16 PM
you have not defined the variables correctly, it should have like this:-

document.formname.textfieldname.value

eg.

<form name="order">

<input type="text" name="price">
<input type="text" name="qty">
<input type="text" name="extendedPrice">

..........
........

now inside function write

var price=document.order.price.value
var qty=document.order.qty.value

now do the calculations


: :Thanks again and one quick question. Do I have my functions defined correctly?
:
: u can ,make a button which will calculate the price,salestex etc. and call the functions onclick.
: :
: : or u can call the function onfocus or onblur in the textfield
: :
: :
: :
: : : 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>
: : :
: : : 2444 Homeworth Rd.
: : :
: : : Alliance, OH 44601
: : :
: : : 330 525-7939
: : : </font>
: : : </CENTER>
: : :
: : : <hr width ="75%" Align=center size ="5" color="#CC9900">
: : :
: : : <FONT SIZE=4> <FONT FACE= "Times New Roman">
: : : Please enter the following information to process your order.
: : : </FONT>
: : :
: : :
: : : <PRE>
: : : <FONT SIZE=3> <FONT FACE= "Times New Roman">
: : : <FORM>
: : : <b>SOLD TO: SHIP TO:</b>
: : :
: : : Company Name: <INPUT type="text" name="CoName1" Size=30> Company Name: <INPUT type="text" name="CoName2" Size=30>
: : :
: : : Address: <INPUT type="text" name="AdName1" Size=30> Address: <INPUT type="text" name="AdName2"Size=30>
: : :
: : : City, State, Zip: <INPUT type="text" name="CSZName1"Size=30> City, State, Zip: <INPUT type="text" name="CSZName2"Size=30>
: : :
: : : Contact Person: <INPUT type="text" name="CPName1"Size=30> Contact Person: <INPUT type="text" name="CPName2"Size=30>
: : :
: : : 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>
: : :
: : :
: :
: :
: :
: :
:
:

Report
Re: Thank You very much Ayanroy Posted by kady63 on 21 Oct 2002 at 2:48 PM
Thank You again! I will try your advice.
Kate:


you have not defined the variables correctly, it should have like this:-
:
: document.formname.textfieldname.value
:
: eg.
:
: <form name="order">
:
: <input type="text" name="price">
: <input type="text" name="qty">
: <input type="text" name="extendedPrice">
:
: ..........
: ........
:
: now inside function write
:
: var price=document.order.price.value
: var qty=document.order.qty.value
:
: now do the calculations
:
:
: : :Thanks again and one quick question. Do I have my functions defined correctly?
: :
: : u can ,make a button which will calculate the price,salestex etc. and call the functions onclick.
: : :
: : : or u can call the function onfocus or onblur in the textfield
: : :
: : :
: : :
: : : : 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>
: : : :
: : : : 2444 Homeworth Rd.
: : : :
: : : : Alliance, OH 44601
: : : :
: : : : 330 525-7939
: : : : </font>
: : : : </CENTER>
: : : :
: : : : <hr width ="75%" Align=center size ="5" color="#CC9900">
: : : :
: : : : <FONT SIZE=4> <FONT FACE= "Times New Roman">
: : : : Please enter the following information to process your order.
: : : : </FONT>
: : : :
: : : :
: : : : <PRE>
: : : : <FONT SIZE=3> <FONT FACE= "Times New Roman">
: : : : <FORM>
: : : : <b>SOLD TO: SHIP TO:</b>
: : : :
: : : : Company Name: <INPUT type="text" name="CoName1" Size=30> Company Name: <INPUT type="text" name="CoName2" Size=30>
: : : :
: : : : Address: <INPUT type="text" name="AdName1" Size=30> Address: <INPUT type="text" name="AdName2"Size=30>
: : : :
: : : : City, State, Zip: <INPUT type="text" name="CSZName1"Size=30> City, State, Zip: <INPUT type="text" name="CSZName2"Size=30>
: : : :
: : : : Contact Person: <INPUT type="text" name="CPName1"Size=30> Contact Person: <INPUT type="text" name="CPName2"Size=30>
: : : :
: : : : 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>
: : : :
: : : :
: : :
: : :
: : :
: : :
: :
: :
:
:

Report
Re: Thank You very much Ayanroy Posted by kady63 on 21 Oct 2002 at 2:48 PM
Thank You again! I will try your advice.
Kate:


you have not defined the variables correctly, it should have like this:-
:
: document.formname.textfieldname.value
:
: eg.
:
: <form name="order">
:
: <input type="text" name="price">
: <input type="text" name="qty">
: <input type="text" name="extendedPrice">
:
: ..........
: ........
:
: now inside function write
:
: var price=document.order.price.value
: var qty=document.order.qty.value
:
: now do the calculations
:
:
: : :Thanks again and one quick question. Do I have my functions defined correctly?
: :
: : u can ,make a button which will calculate the price,salestex etc. and call the functions onclick.
: : :
: : : or u can call the function onfocus or onblur in the textfield
: : :
: : :
: : :
: : : : 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>
: : : :
: : : : 2444 Homeworth Rd.
: : : :
: : : : Alliance, OH 44601
: : : :
: : : : 330 525-7939
: : : : </font>
: : : : </CENTER>
: : : :
: : : : <hr width ="75%" Align=center size ="5" color="#CC9900">
: : : :
: : : : <FONT SIZE=4> <FONT FACE= "Times New Roman">
: : : : Please enter the following information to process your order.
: : : : </FONT>
: : : :
: : : :
: : : : <PRE>
: : : : <FONT SIZE=3> <FONT FACE= "Times New Roman">
: : : : <FORM>
: : : : <b>SOLD TO: SHIP TO:</b>
: : : :
: : : : Company Name: <INPUT type="text" name="CoName1" Size=30> Company Name: <INPUT type="text" name="CoName2" Size=30>
: : : :
: : : : Address: <INPUT type="text" name="AdName1" Size=30> Address: <INPUT type="text" name="AdName2"Size=30>
: : : :
: : : : City, State, Zip: <INPUT type="text" name="CSZName1"Size=30> City, State, Zip: <INPUT type="text" name="CSZName2"Size=30>
: : : :
: : : : Contact Person: <INPUT type="text" name="CPName1"Size=30> Contact Person: <INPUT type="text" name="CPName2"Size=30>
: : : :
: : : : 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>
: : : :
: : : :
: : :
: : :
: : :
: : :
: :
: :
:
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.