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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

masterpassCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.