2Truth 2Truth - 1 year ago 99
jQuery Question

Changing price based on quantity

I have a dynamic table with products, prices, and quantity. I want to change the price when the quantity is changed. here is my XHTML table

<caption>Checkout Time!</caption>
<td colspan="4" align="right">
<input type="button" value="Checkout!" />
<td class="description">Folger's Gourmet Instant Coffee 24 count box.</td>
<input type="text" id="price" readonly value="12.50" class="readonly" />
<input type="text" id="quantity" value="1" />
<input type="text" id="total" readonly value="12.50" class="readonly" />

I just want to use JQuery. Can someone help?

Answer Source

Try this:

    var tot = $('#price').val() * this.value;

Demo here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download