Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. <!-- size -->
  2.  
  3. <label style="width: auto; margin-top: 2%;" class="btn btn-default buying-selling border_radio espacamento_tipo">
  4. <input type="radio" required value="size " name="size[]" id="option1" autocomplete="off" style="width: auto" placeholder="2">
  5.  
  6. <span class="buying-selling-word" style="overflow: visible">SIZE 1</span>
  7. </label>
  8.  
  9. <label style="width: auto; margin-top: 2%;" class="btn btn-default buying-selling border_radio espacamento_tipo">
  10. <input type="radio" required value="size " name="size[]" id="option1" autocomplete="off" style="width: auto" placeholder="3">
  11.  
  12. <span class="buying-selling-word" style="overflow: visible">SIZE 2</span>
  13. </label>
  14.  
  15.  
  16. <!-- recording-->
  17.  
  18. <label style="width: auto; margin-top: 2%;" class="btn btn-default buying-selling border_radio espacamento_tipo">
  19.  
  20. <input type="radio" required value="recording" name="recording[]" id="option1" autocomplete="off" style="width: auto" placeholder="4">
  21.  
  22. <span class="buying-selling-word" style="overflow: visible">recording</span>
  23. </label>
  24. <label style="width: auto; margin-top: 2%;" class="btn btn-default buying-selling border_radio espacamento_tipo">
  25.  
  26. <input type="radio" required value="recording" name="recording[]" id="option1" autocomplete="off" style="width: auto" placeholder="5">
  27.  
  28. <span class="buying-selling-word" style="overflow: visible">recording1</span>
  29. </label>
  30.  
  31.  
  32.  
  33. <!--TOTAL -->
  34.  
  35. <div class="col-sm-12 espacamento">
  36. <div class="col-md-6" style="float: left">
  37.  
  38. <h4>Total</h4>
  39. </div>
  40. <div class="col-md-6" style="float: right" id="result">
  41. <h4 style="text-align:center" id="total"> </h4>
  42. </div>
  43.  
  44. </div>
  45.  
  46.  
  47.  
  48. <script>
  49.  
  50. //size
  51. const inputs_size = [...document.querySelectorAll("input[name='size[]']")];
  52. const res_size = document.getElementById("result");
  53. const res_price_size = document.getElementById("size_price");
  54.  
  55. inputs_size.forEach(x => x.addEventListener("change", () => {
  56.  
  57. res_size.innerHTML = ""; //clear the result
  58. res_price_size.innerHTML = ""; //clear the result
  59.  
  60. inputs_size.forEach(y => res_size.innerHTML += y.checked ? y.value + "<br>" : "");
  61. inputs_size.forEach(y => res_price_size.innerHTML += y.checked ? y.placeholder + "€" + "<br>" : "");
  62.  
  63. }));
  64.  
  65.  
  66. //recording
  67. const inputs_recording = [...document.querySelectorAll("input[name='recording[]']")];
  68. const res_recording = document.getElementById("result_recording");
  69. const res_price_recording = document.getElementById("resultado_recording_price");
  70.  
  71. inputs_gravacao.forEach(x => x.addEventListener("change", () => {
  72.  
  73. res_recording.innerHTML = ""; //clear the result
  74. res_price_recording.innerHTML = ""; //clear the result
  75.  
  76. inputs_recording.forEach(y => res_recording.innerHTML += y.checked ? y.value + "<br>" : "");
  77. inputs_recording.forEach(y => res_price_recording.innerHTML += y.checked ? y.placeholder + "€" + "<br>" : "");
  78.  
  79. }));
  80.  
  81.  
  82.  
  83. var price = 10;
  84. var product_price= parseFloat(price);
  85.  
  86.  
  87. // sum
  88. var inputs = [...document.querySelectorAll("input[type='radio'")];
  89. inputs.forEach(x => x.addEventListener("change", () => {
  90.  
  91. sum = product_price;
  92. sum += parseFloat(x.placeholder) ;
  93.  
  94. document.getElementById("total").innerHTML = parseFloat(sum.toFixed(2)) + "€";
  95.  
  96. }));
  97.  
  98. document.getElementById("total").innerHTML = parseFloat(sum.toFixed(2)) + "€";
  99.  
  100.  
  101. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement