Question: Start from the solution for the discount calculator problem Posted below Do these steps------ a) Add data validation. b) Add a sales tax calculation of
Start from the solution for the discount calculator problem Posted below
Do these steps------ a) Add data validation.
b) Add a sales tax calculation of 8% based on the discounted price. Then, display the sales tax rate, the calculated sales tax amount, and the sales total after the discounted price.
c) Display the results below the form instead of on a separate page.
d) After each calculation, set the values in the text boxes to empty strings.
INDEX.HTML------
Product Discount Calculator
MAIN.CSS------
body { font-family: Arial, Helvetica, sans-serif; margin: 1em; padding: 0; }
main { display: block; width: 450px; margin: 0 auto; padding: 1.5em; background: white; border: 2px solid navy; }
h1 { color: navy; }
label { width: 10em; padding-right: 1em; float: left; }
#data input { float: left; width: 15em; margin-bottom: .5em; }
#data span { padding-left: .25em; }
#buttons input { float: left; margin-bottom: .5em; }
br { clear: left; }
DISPLAY_DISCOUNT.PHP
// calculate the discount $discount = $list_price * $discount_percent * .01; $discount_price = $list_price - $discount;
// apply currency formatting to the dollar and percent amounts $list_price_formatted = "$".number_format($list_price, 2); $discount_percent_formatted = number_format($discount_percent, 1)."%"; $discount_formatted = "$".number_format($discount, 2); $discount_price_formatted = "$".number_format($discount_price, 2);
// escape the unformatted input $product_description_escaped = htmlspecialchars($product_description); ?>
Product Discount Calculator
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
