Advertisement
Grangler

Untitled

Apr 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. let btnSubmit = document.getElementById("submit");
  2.  
  3. let allInputs = document.getElementsByTagName("input");
  4. for (let i = 0; i < allInputs.length; i++) {
  5. allInputs[i].addEventListener("change", displayCost);
  6. }
  7.  
  8. function ticketPrice()
  9. {
  10. let choice = this.value;
  11. let ticketPrice = document.getElementById("ticketPrice");
  12.  
  13. if (choice == "Phantom")
  14. {
  15. ticketPrice.innerHTML = "79"
  16. }
  17. if (choice == "Hamilton")
  18. {
  19. ticketPrice.innerHTML = "85"
  20. }
  21. if (choice == "Lion King")
  22. {
  23. ticketPrice.innerHTML = "67"
  24. }
  25. if (choice == "Miss Saigon")
  26. {
  27. ticketPrice.innerHTML = "83"
  28. }
  29. }
  30.  
  31. function discountInput()
  32. {
  33. let displaydiscountInput = this.value;
  34. let seats = document.getElementById("seats");
  35. let discount = document.getElementById("discount");
  36.  
  37. if (seats >=1 && seats <= 5) {
  38. discount.innerHTML = "0%";
  39. }
  40.  
  41. else if (seats >= 6 && seats <= 9) {
  42. discount.innerHTML = "10%";
  43. }
  44.  
  45. else if (seats >= 10) {
  46. discount.innerHTML = "15%";
  47. }
  48. }
  49.  
  50. function displayCost() {
  51. var displayCostChoice = this.value;
  52. let deliveryCost = document.getElementById("deliveryCost");
  53.  
  54. if (displayCostChoice == "e-ticket") {
  55. deliveryCost.innerHTML = "Free";
  56. }
  57. else if (displayCostChoice == "box_office") {
  58. deliveryCost.innerHTML = "£1.50";
  59. }
  60. else {
  61. deliveryCost.innerHTML = "£3.99";
  62. }
  63. }
  64.  
  65. var basePrice = 0.00;
  66. $(".calculate").change(function(){
  67. newPrice = basePrice;
  68. $(".calculate option:selected").each(function() {
  69. newPrice +=$(this).data('price')
  70. });
  71. $("#ticketPrice").html(newPrice);
  72. });
  73.  
  74. $(".totalPrices").change(function(){
  75. totalPrices = deliveryCostVar;
  76. $(".totalPrices option:selected").each(function() {
  77. totalPrices +=$(this).data('price')
  78. });
  79. $("#totalPrice").html(totalPrices);
  80. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement