I have a sort of calculator form and i want to have a button to clear the results each time it is used. for now I am using the history.back() because other things ive tried just reload the page with the finished calculations still on the page. I am sure Im overlooking something very simple, but hey its early.
[php]
Thickness(inches):
Width(inches):
Length(feet):
Quantity:
Price per Boardfoot: *optional
<?php /* The following assigns a dummy value to $_POST values to avoid index errors */ if (!isset($_POST['thickness'])) { //If not isset -> set with dummy value $_POST['thickness'] = "undefine"; } $thickness=make_safe($_POST['thickness']); /////////////////////////////////////////////////// if (!isset($_POST['width'])) { //If not isset -> set with dummy value $_POST['width'] = "undefine"; } $width=make_safe($_POST['width']); /////////////////////////////////////////////////// if (!isset($_POST['length'])) { //If not isset -> set with dummy value $_POST['length'] = "undefine"; } $length=make_safe($_POST['length']); /////////////////////////////////////////////////// if (!isset($_POST['quantity'])) { //If not isset -> set with dummy value $_POST['quantity'] = "undefine"; } $quantity=make_safe($_POST['quantity']); /////////////////////////////////////////////////// if (!isset($_POST['price'])) { //If not isset -> set with dummy value $_POST['price'] = "undefine"; } $price=make_safe($_POST['price']);//calculator process
$total = (($thickness * $width * ($length * 12)) / 144) * $quantity;
$cost = “$” . number_format($total*$price,2);
if(empty($total)){} else {
echo “
Qty: (” . $quantity . ") " . $thickness . “x” . $width . “x” . $length . “
”;echo "
Total Boardfeet: " . number_format($total,2) . “
”;if(empty($price)){} else { //optional. if price is not empty() the following executes
echo "
Total Cost: " . “” . $cost . “” . “
”;}
}
?>[/php]