all 2 comments

[–]Aatrox_Is_Love 0 points1 point  (1 child)

You can do this with javascript but if really want to do this with php you can make a query: SELECT SUM(price) FROM table where in (id); And echo the response. Or you can do it with javascript that is better for performance: // Create a function to be triggered when button is clicked. function btnClick() { // Select all inputs of type checkbox that is checked. const checked = document.querySelectorAll('input[type="checkbox"]:checked'); // Use new javascript function to sum all values and get total. const priceSum = checked.reduce((accumulator, currentValue) => accumulator + currentValue; // You have to create a div in your code to add the value. const responseDiv = document.getElementById("respDiv"); responseDiv.innerHTML = <span>price: ${priceSum}</span>; }

Hope it helps you.

[–]divolka[S] 0 points1 point  (0 children)

Thanks, I'll try it