Created
November 2, 2018 07:43
-
-
Save ra100/af03d4ecb44c2e5d37d45885cba625de to your computer and use it in GitHub Desktop.
elephant-carpaccio
This file contains 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
<html> | |
<head> | |
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" | |
crossorigin="anonymous"> | |
</script> | |
</head> | |
<h1>Elephant Shop</h1> | |
<div> | |
<h3>We have</h3> | |
<table> | |
<thead> | |
<tr> | |
<th> | |
Item name | |
</th> | |
<th> | |
price per piece without Tax | |
</th> | |
<th> | |
amount of pieces | |
</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td class="name"> | |
Elephant Brisket | |
</td> | |
<td class="price"> | |
$26.70 | |
</td> | |
<td> | |
<input type="number" value="0" /> | |
</td> | |
</tr> | |
<tr> | |
<td class="name"> | |
Elephant Rib eye | |
</td> | |
<td class="price"> | |
$35.25 | |
</td> | |
<td> | |
<input type="number" value="0" /> | |
</td> | |
</tr> | |
<tr> | |
<td> | |
Elephant Sirloin | |
</td> | |
<td class="price"> | |
$19.99 | |
</td> | |
<td> | |
<input type="number" value="0" /> | |
</td> | |
</tr> | |
<tr> | |
<td> | |
Elephant T-Bone | |
</td> | |
<td class="price"> | |
$48.50 | |
</td> | |
<td> | |
<input type="number" value="0" /> | |
</td> | |
</tr> | |
<tr> | |
<td> | |
Elephant Flank | |
</td> | |
<td class="price"> | |
$22.00 | |
</td> | |
<td> | |
<input type="number" value="0" /> | |
</td> | |
</tr> | |
</tbody> | |
</table> | |
<br> | |
Total amount (with tax for UT) is: $<span id="total">0</span> | |
<p> | |
Order by email | |
<a href="mailto:elephant@merck.com?subject=Order&body=">elephant@merck.com</a> | |
</p> | |
</div> | |
<script> | |
const tax = 1.0685 | |
const generateMail = (total) => { | |
let mail = 'mailto:elephant@merck.com?subject=Order&body=I order ' | |
$('tbody tr').each(function() { | |
const value = $(this).find('input').val() | |
const price = $(this).children('.price').text().trim() | |
const name = $(this).first().text().trim() | |
if (value > 0) { | |
mail += "\n" + name + ': x' + value + "\n" | |
} | |
}) | |
$('a').attr('href', mail) | |
} | |
$(document).ready(function () { | |
$('input').on('change', function (event) { | |
let total = 0 | |
$('input').each(function () { | |
const value = $(this).val() | |
const price = $(this).parents('tr').children('.price').text().trim().replace('$', '') | |
$('#total').text(price * value) | |
total += value * price | |
}) | |
total = total * tax | |
$('#total').text(total) | |
generateMail() | |
}) | |
}) | |
</script> | |
<body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment