I have a form of multiple checkboxes with each corresponding numeric values. I want the PHP to show the sum of the values from only the checked checkboxes. If checkbox 1 has a value of 80; checkbox 2 has 21; and checkbox three has 15; then as an example, if the user only checked checkboxes 3 and 2 then the PHP must output 36.
Here's what I have so far, concerning the HTML and CSS codes https://jsfiddle.net/nerdfighter/tmz1ymeL/4/ (jsFiddle) Any help would be appreciated! Thanks
<form action="index.php" method="get"/>
PHP:
$val = 0;
if(isset($_POST['chck1']){
$val += $_POST['chck1'];
}
if(isset($_POST['chck2']){
$val += $_POST['chck2'];
}
if(isset($_POST['chck3']){
$val += $_POST['chck3'];
}
echo $val;