PDA

View Full Version : calculate sub total & Total


NinjaTurtle
08-13-2002, 08:40 AM
Dear ,

i face a problem.... that is:
User can choose 2 type of quantity types, example: 1 carton(dozen) is 12 boxes, user allow to choose box or dozen or both, that's mean there are 1 unit price, 2 type of quantity types(carton and box), and 2 amount(1 for carton, 1 for box), then 1 sub total for every categories, lastly there is a Total that cover all amount that user chose!! p/s : some items may only have one measure, this is the problem that make me do calculation!!!

example coding:

<table width="90%" border="1">
<tr bgcolor="#CCCCCC">
<td colspan="5" >A : Fruits</td>
</tr>
<tr>
<td >item code</td>
<td >item</td>
<td >unit price</td>
<td >quantity</td>
<td >amount</td>
</tr>
<tr>
<td width="11%" height="2">155</td>
<td width="53%" height="2">Apple</td>
<td width="10%" height="2">0.5</td>
<td width="11%" height="2">
<input type="text" name="textfield" size="3">
(carton)<br>
<input type="text" name="textfield22" size="3">
( box )</td>
<td width="15%" height="2"> $
<input type="text" name="textfield2" size="8">
<br>
$
<input type="text" name="textfield23" size="8">
</td>
</tr>
<tr>
<td width="11%" height="2">455</td>
<td width="53%" height="2">Orange</td>
<td width="10%" height="2">0.7</td>
<td width="11%" height="2">
<input type="text" name="textfield222" size="3">
( box )</td>
<td width="15%" height="2">$
<input type="text" name="textfield232" size="8">
</td>
</tr>
<tr>
<td colspan="4">
<div align="right">Subtotal:</div>
</td>
<td width="15%"> $
<input type="text" name="textfield2322" size="8">
</td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="5">B. Computer</td>
</tr>
<tr>
<td width="11%">233</td>
<td width="53%">Mouse( 1 box @ 12 units)</td>
<td width="10%">1.54</td>
<td width="11%">
<input type="text" name="textfield3" size="3">
( box )<br>
<input type="text" name="textfield223" size="3">
( unit ) </td>
<td width="15%">$
<input type="text" name="textfield24" size="8">
<br>
$
<input type="text" name="textfield233" size="8">
</td>
</tr>
<tr>
<td width="11%">555</td>
<td width="53%">Monitor</td>
<td width="10%">100</td>
<td width="11%">
<input type="text" name="textfield2232" size="3">
( unit ) </td>
<td width="15%">$
<input type="text" name="textfield2332" size="8">
</td>
</tr>
<tr>
<td colspan="4">
<div align="right">Sub total :</div>
</td>
<td width="15%"> $
<input type="text" name="textfield2322" size="8">
</td>
</tr>
<tr>
<td colspan="4">
<div align="right">Total :</div>
</td>
<td width="15%"> $
<input type="text" name="textfield2322" size="8">
</td>
</tr>
</table>