SHARE
TWEET

Untitled

a guest Nov 22nd, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let margarita = {
  2.     'S': 3,
  3.     'M': 4,
  4.     'L': 5,
  5.     'XL': 6
  6. };
  7. let capricciosa = {
  8.     'S': 12,
  9.     'M': 13,
  10.     'L': 14,
  11.     'XL': 15
  12. };
  13. let diavola = {
  14.     'S': 5,
  15.     'M': 6,
  16.     'L': 7,
  17.     'XL': 8
  18. };
  19. let pascolo = {
  20.     'S': 6,
  21.     'M': 7,
  22.     'L': 8,
  23.     'XL': 9
  24. };
  25. let quattroStagioni = {
  26.     'S': 8,
  27.     'M': 9,
  28.     'L': 10,
  29.     'XL': 11
  30. };
  31. let giardiniera = {
  32.     'S': 10,
  33.     'M': 11,
  34.     'L': 12,
  35.     'XL': 13
  36. };
  37. let pizza1 = new Pizza('Margarita', 'Tomato and mozzarella', margarita);
  38. let pizza2 = new Pizza('Capriccosa', 'Tomato, mozzarella, olives, ham, boiled egg', capricciosa);
  39. let pizza3 = new Pizza('Diavola', 'Tomato, mozzarella, onion, chili pepper', diavola);
  40. let pizza4 = new Pizza('Pascolo', 'Mozzarella, stracchino, prosciutto, rocket', pascolo);
  41. let pizza5 = new Pizza('Quattro stagioni', 'Tomato, mozzarella, mushrooms, artichokes', quattroStagioni);
  42. let pizza6 = new Pizza('Giardiniera', 'Mozzarella, courgettes, aubergines, peppers', giardiniera);
  43.  
  44. let pizzas = [
  45.     pizza1,
  46.     pizza2,
  47.     pizza3,
  48.     pizza4,
  49.     pizza5,
  50.     pizza6
  51. ];
  52.  
  53. const selPizzaSize = document.querySelectorAll('.size');
  54. const btnOrder = document.querySelectorAll('.order-btn');
  55. const orderContent = document.querySelector('#order-content');
  56.  
  57. selPizzaSize.forEach(e => {
  58.         let price;
  59.         pizzas.forEach(pizza => {
  60.             if(pizza.name == e.id)
  61.                 price = pizza.prices[e.value];
  62.         })
  63.         e.previousElementSibling.innerHTML = price + ' $';
  64. });
  65.  
  66. selPizzaSize.forEach(select => {
  67.     select.addEventListener('change', (e) =>{
  68.         let price;
  69.         pizzas.forEach(pizza => {
  70.             if(pizza.name == e.target.id)
  71.                 price = pizza.prices[e.target.value];
  72.         })
  73.         console.log(e.target.previousSibling);
  74.         e.target.previousElementSibling.innerHTML = price + ' $';
  75.     });
  76. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top