Advertisement
Guest User

Untitled

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