How to calculate cost of an order on an online menu in javascript
<p>I am building a v simple online menu for a takaway website - it is in an html table. I have a basic function that picks up the item's value, stored in one TD, then the quantity ordered, stored in another TD, and calculates the cost of the order accordingly. Only issue is I have hardcoded the id's of the 1st product and 1st product quantity into my function to get it to work for that item, but there is a list of about 20 items. Short of repeating my function 20 times, I cant work out how I can give the function the correct 2 ids for each item on the menu. The menu is here <a href="http://www.port80services.com/curry/menu.html" rel="nofollow">http://www.port80services.com/curry/menu.html</a></p>

<p>I am sure it should be relatively simple, but javascript just isnt my thing! </p>

<p>function:</p>

<pre><code>function toPay(){

   var form = document.forms['form'];

   var itemcost = document.getElementById('meat_samosa_price').innerHTML;

   var qty = form.meat_samosa_qty.value;

      var res = Math.abs(itemcost  * qty);

    document.getElementById('order-total').innerHTML = "order total = €"+ res;

}
</code></pre>
