SHARE
TWEET

Untitled

a guest Nov 22nd, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     var tentativa;
  2.  
  3.     //material
  4.     var inputs_material = [...document.querySelectorAll("input[name='material[]']")];
  5.     var res_material = document.getElementById("resultado_material");
  6.     var res_preco_material = document.getElementById("resultado_material_preco");
  7.  
  8.     inputs_material.forEach(x => x.addEventListener("change", () => {
  9.         //esta função corre quando houve alteração de um dos checkboxes
  10.         res_material.innerHTML = ""; //limpar o resultado
  11.         res_preco_material.innerHTML = ""; //limpar o resultado
  12.  
  13.         //passar em todos os inputs e adicionar o seu value e <br> se tiver checked
  14.         inputs_material.forEach(y => res_material.innerHTML += y.checked ? y.value + "<br>" : "");
  15.         inputs_material.forEach(y => res_preco_material.innerHTML += y.checked ? y.placeholder + "€" + "<br>" : "");
  16.  
  17.  
  18.         tentativa= res_preco_material.innerHTML;
  19.         console.log(tentativa + " ola");
  20.  
  21.  
  22.     }));
  23.  
  24.  
  25. document.getElementById("total").innerHTML= tentativa;
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