calculate sum of values on an order page

I have created a system for a company to take manual orders of products over the phone.
The manual order entry page code is shown below.

The user enters: Quantity, Product Name, Product Price, Delivery Cost. I want

I would like each line to be added up separately (ie. Quantity * Product Price) and then grand total to show the sum of each line plus the delivery cost.


This is only being done for the users benefit at time of entry because when the submit this page, a process order PHP page adds everything together and enters it into the DB.

I assume this could easily be done in javascript.

Could anyone offer any pointers?

Many Thanks

<table>
  <tr>
    <td>Qty</td>
    <td>Item</td>
    <td>Unit Price</td>
    <td>Total</td>
  </tr>
  
  <tr>
    <td><input name="manualQty[0]" type="text" size="5" maxlength="2"  />
      </center></td>
    <td><input name="manualProduct[0]" type="text"/></td>
    <td><input name="manualPriceEach[0]" type="text"/></td>
    <td><input name="subtotal[0]" type="text" readonly/></td>
  </tr>
  
  <tr>
    <td><input name="manualQty[1]" type="text" size="5" maxlength="2"  /></td>
    <td><input name="manualProduct[1]" type="text"/></td>
    <td><input name="manualPriceEach[1]" type="text"  /></td>
    <td><input name="subtotal[1]" type="text" readonly  /></td>
  </tr>
  
  <tr>
    <td colspan="2">&nbsp;</td>
    <td>Sub-total:</td>
    <td><input name="subtotal2" type="text" readonly/></td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
    <td>Delivery:</td>
    <td><input name="manualShippingCost" type="text" /></td>
  </tr>
  <tr>
    <td colspan="2"></td>
    <td>Grand Total:</td>
    <td><input name="manualGrandTotal" type="text" /></td>
  </tr>
</table>

Open in new window

Steve TinsleyAsked:
Who is Participating?
 
masterpassConnect With a Mentor Commented:
0
 
Steve TinsleyAuthor Commented:
That is similar to what I want to achieve.
The extra thing I want to do is have a line subtotal for each item.

and then add all those up for the grandtotal.

Any pointers?
0
 
masterpassCommented:
you can use the same concept and fill up the line total by just multiplying the values,

Then follow the almost same JS to get the grand total ...
0
 
Steve TinsleyAuthor Commented:
If I have several lines of products in the order do I need several javascripts? One for each?? and then one for the grand total??

Is there a better way of doing it ??

0
 
Steve TinsleyAuthor Commented:
Any one else with a little more help?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.