PDA

View Full Version : How to Calculate Total



Sara8
04-16-2008, 12:49 PM
Hi,
I've been trying for days and looked all over the internet, but still need help.

I am a student and have created an order form for a fictitious company. I want to calculate products selected in 3 categories which are Collars, Tags & Clothes. I have included a box for quantity for each category.
I need to show a total cost in a message box at the end of the form.

This is the relevant part of the form.

<td> <b>Collars</b></td>
</tr>
<tr>
<td><select name=products>
<option>Please select style
<option value="$39.99">Collar Pink Leather $39.99
<option value="$44.99">Collar White Rhinestones $44.99
<option value= "$44.99">Collar Pet Name $44.99
<option value="$24.99">Collar Flower Jewels $24.99
</select></td>
<td><b>Quantity<b>
<input type=hidden name="Item" value="Name">
<input type=text name="Qty" value="1" size="3">
<input type=hidden name="Price" value="10">

</td>
</tr>
<tr><td><br></td></tr>
<tr>
<td> <b>Tags</b></td>
</tr>
<tr>
<td><select name=Tags>
<option>Please select style
<option value="$39.99">Rhinestone Bone $24.99
<option value="$44.99">Black & Silver Bone $24.99
<option value= "$44.99">Red Dog Paw $24.99
<option value="$24.99">Black Dog Paw $24.99
</select></td>
<td><b>Quantity<b>
<input type=hidden name="Item" value="Name">
<input type=text name="Qty" value="1" size="3">
<input type=hidden name="Price" value="10">
</td>
</tr>
<tr><td><br></td></tr>
<tr>
<td> <b>Clothes</b></td>
</tr>
<tr>
<td><select name=Clothes>
<option>Please select style
<option value="$39.99">Wedding Dress $99.99
<option value="$44.99">Flower Jumper $49.99
<option value= "$44.99">Polka Dot Dress $35.99
<option value="$24.99">Lucky Dog T-Shirt $24.99
</select></td>
<td><b>Quantity<b>
<input type=hidden name="Item" value="Name">
<input type=text name="Qty" value="1" size="3">
<input type=hidden name="Price" value="10">
</td>

Can anyone out there help me.
Thank you.

Nile
04-17-2008, 04:07 AM
Lemme get this straight, as people select there options, you want the value in the total changed?
This can be done with a simple javascript function.
But, I don't want to make it till you clarify that this is what you want.

boogyman
04-17-2008, 01:44 PM
Please refer to #8 on Posting Policies and Regulations (http://dynamicdrive.com/forums/showthread.php?t=24866)

take the values of the three categories and add them together and put them in a fourth box


Nile... This is most likely a homework assignment, since she said she was a student so let her try to figure it out herself.
Sara if you have questions about how to get the value of an input refer to the javascript function getElementById