tnx for everyone, i found this LINK
and that’s excatly what i was looking for.
function getTotal(){
var total = 0;
$('.sum').each(function(){
total += parseFloat(this.innerHTML)
});
$('#total').text(total);
}
getTotal();
$('.qty').keyup(function(){
var parent = $(this).parents('tr');
var price = $('.price', parent);
var sum = $('.sum', parent);
var value = parseInt(this.value) * parseFloat(price.get(0).innerHTML||0);
sum.text(value);
getTotal();
})
Solution 2 :
add $sum = 0; variable before while and put $sum += $row['price']; inside your while you can access $sum in Total Price <td>.
maybe you need int cast for $row['price'].
@TangentiallyPerpendicular abusive replies does not make a sense, anyway he needs help with his current code, you could guide him to the right place to get his answer instead of that, i think we are here to help each other,
Comment posted by imvain2
I see your PHP/HTML, but I don’t see your attempt at solving the problem. You should try posting the javascript that you have tried to create but couldn’t get to work.
Comment posted by Tangentially Perpendicular
@BurhamB.Soliman This question is typical of so many questions here. The OP has posted something which he may or may not have produced himself, and asked a question that shows no effort whatsoever. It is a requirement of this site that askers have made an honest attempt to solve their problem before they ask. Without that requirement the site risks descending into a code-writing free-for-all that doesn’t mesh with the site’s objectives.
Comment posted by jquery selectors
you need to use jquery to call the result of the selected price and multiply it by the quantity .. so u could give it a try and do some search about jquery or javascript, and if you failed u can show up wt u tried and we would help you to solve it, here is a ref about
Comment posted by Saar Asor
Tangentially Perpendicular i dont want anyone to wrtie my code, i just want help… link to somewhere or some help… maybe i wasn’t clear but that’s only what i wanted… some help… any way iposted the solution for what i wanted, tnx!
Comment posted by imvain2
This doesn’t take into consideration the qty input that will be used AFTER the php is generated and sent to the browser.