Generate Total Price, multiple products on one page
<p>I'm trying to generate the total price on a one page store.</p>

<p>I have different products on the same page laid out like this within a foreach:</p>

<pre><code>&lt;input type="hidden" name="price_&lt;?=$product_id?&gt;" value="&lt;?=$product_price?&gt;" /&gt;
&lt;input type="text" name="&lt;?=$product_id?&gt;" value="" onchange="calculateTotal();" /&gt;
</code></pre>

<p>So, the first input is hidden and contains the price of the product. The second input contains the quantity, with the name set as the product_id. The only issue is that there can be multiple inputs on one page.</p>

<p>Which would be the best way to do it? Either using Javascript to calculate the price, or an Ajax post and using PHP to do the calculations.</p>
