Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 19 lines (14 sloc) 0.578 kb
534782d @hectorcorrea First commit
authored
1 totalPrice = (price, discountPercent = 0, taxPercent = 10) ->
09216e3 @hectorcorrea switched tabs to spaces
authored
2 discount = (price * (discountPercent/100))
3 tax = (price - discount) * (taxPercent/100)
4 price - discount + tax
534782d @hectorcorrea First commit
authored
5
6 updateTotalPrice = ->
09216e3 @hectorcorrea switched tabs to spaces
authored
7 itemPrice = $("#txtPrice").val()
8 discount = $("#txtDiscount").val() unless $("#txtDiscount").val() is ""
9 tax = $("#txtTax").val() unless $("#txtTax").val() is ""
534782d @hectorcorrea First commit
authored
10
09216e3 @hectorcorrea switched tabs to spaces
authored
11 total = totalPrice(itemPrice, discount, tax)
12
13 $("#txtTotal").val(total)
534782d @hectorcorrea First commit
authored
14
15 $ ->
09216e3 @hectorcorrea switched tabs to spaces
authored
16 $("#txtPrice").change updateTotalPrice
17 $("#txtDiscount").change updateTotalPrice
18 $("#txtTax").change updateTotalPrice
Something went wrong with that request. Please try again.