Good day.
Interested in this question: how to calculate the amount (total price) depending on the specific price and quantity entered in the input field? There is a code, how to change the value in the field, but here it’s impossible to calculate the amount as it is correct.
jQuery
//button input var sum = parseInt($('.sum_price').text()); $('.degr').click(function(){ var vI = $(this).parent().find('input').val(); if(vI > 0){ vI --; $(this).parent().find('input').val(vI); } var pr_m = parseInt($(this).parent().parent().find($('.price_sp')).text())*vI; }); $('.incr').click(function(){ var vI = $(this).parent().find('input').val(); vI++; $(this).parent().find('input').val(vI); var pr_p = parseInt($(this).parent().parent().find($('.price_sp')).text())*vI; });
I wrote jQuery myself, can someone come in handy. There is no particular experience :)
HTML
<p>Стоимость заказа: <span class="sum_price">0</span> руб.</p> <p>Детали заказа:</p> <table class="form_goods_order"> <tr> <td class="name_goods">Набор экономного болельщика</td> <td class="price_goods"><span class="price_sp">695</span> р.</td> <td class="count"><img src="images/count_left.gif" title="Уменьшить" alt="Уменьшить" class="degr"/><input type="text" name="nab1" id="nab1" value="0" /><img src="images/count_right.gif" title="Увеличить" alt="Увеличить" class="incr" /></td> </tr>
An example of working on the site , if you click on the buy button.