Created
October 4, 2017 00:21
-
-
Save ryanhburbank/259f78b175e708f7f222ac59a1cd325c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Assignment 2</title> | |
| <meta charset="UTF-8"> | |
| /*Code for button CSS | |
| .button { | |
| background-color="#00FFCC" | |
| color="#CCAABB" | |
| } | |
| */ | |
| </head> | |
| <body> | |
| <h1>Assignment 2</h1> | |
| <form action="" method="post" name="calcPrice"> | |
| <input type="text" id="nombre" autofocus>Name<br /> | |
| <input type="text" id="ordenado" autofocus>Number of orders<br /> | |
| <input type="number" value="5.31" readonly="true">Cost of widget<br /> | |
| <input type="text" name="amount" id="amount" readonly="true"> | |
| <br> | |
| <input type="button" value="Process Order" id="button" onclick="calcPrice();"> | |
| </form> | |
| <script type="text/javascript"> | |
| //Function used to calculate user's total cost | |
| function calcPrice() { | |
| const SALESTAX = 0.0825; | |
| const ITEMPRICE = 5.31; | |
| var userName = document.getElementById("nombre").value; | |
| var quantity = document.getElementById("ordenado").value; | |
| var price = parseFloat(quantity) * parseFloat(ITEMPRICE); | |
| var tax = parseFloat(price) * parseFloat(SALESTAX); | |
| var totalCost = parseFloat(price) + parseFloat(tax); | |
| //Should transfer value from totalCost to amount in html script | |
| document.getElementById("amount").value = "$" + totalCost.toFixed(2); | |
| alert(userName + " your total order cost is $" + totalCost.toFixed(2) + " with $" + tax + " in tax."); | |
| } | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.