I can output the values of the check boxes which are checked, but I want to get a total. I have tried to use sum() to total the values selected but I just keep getting double 0 0.
My checkbox.php
<?php
if(isset($_POST['submit'])){
if(!empty($_POST['shipping'])) {
?>
<div class="container"> <?php
//Loop through shipping array to fetch individual shipping so that we can use them
echo "<h2> Your Shipping Costs are: </h2>";
foreach($_POST['shipping'] as $shipping) {
//Print all the shipping
echo $shipping;
}
}
else{
echo "<b>Please Select at least One Option.</b>";
}
?></div><?php }
?>
then my html
<div class="container">
<form action="checkbox.php" method="post">
<label class="head">Select Your Timezone or Other Shipping Options:</label><br/><br/>
<input type="checkbox" name="shipping[]" value="$190.00"> <label>Freight to Eastern USA</label><br/>
<input type="checkbox" name="shipping[]" value="$245.00"><label>Freight to Western USA</label><br/>
<input type="checkbox" name="shipping[]" value="$75.00"><label>Residential Devivery</label><br/>
<input type="checkbox" name="shipping[]" value="$100.00"><label>Liftgate Service</label><br/>
<input type="checkbox" name="shipping[]" value="$0.00"><label>Will Call</label><br/><br/>
<input type="submit" name="submit" Value="Add to Shopping Cart"/>
</form>
All help greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire