Note that there are some explanatory texts on larger screens.

plurals
  1. POAny way to simplify this code?
    primarykey
    data
    text
    <p>New to javascript! This works, but I have a lot more to do, and it would be great if there was a cleaner way to do this.. open to using jquery if neccesary :)</p> <p>(stack wants me to write more before I submit, though I'm not sure what else to say)</p> <pre><code>&lt;script&gt; function apply(){ var backerPrediction1 = document.getElementById("backer-prediction-1").value; var backerPrediction2 = document.getElementById("backer-prediction-2").value; var backerPrediction3 = document.getElementById("backer-prediction-3").value; var backerPrediction4 = document.getElementById("backer-prediction-4").value; var backerPrediction5 = document.getElementById("backer-prediction-5").value; var backerPrediction6 = document.getElementById("backer-prediction-6").value; var backerPrediction7 = document.getElementById("backer-prediction-7").value; var backerPrediction8 = document.getElementById("backer-prediction-8").value; var backerPrediction9 = document.getElementById("backer-prediction-9").value; var backerPrediction10 = document.getElementById("backer-prediction-10").value; var backerPrediction11 = document.getElementById("backer-prediction-11").value; var backerPrediction12= document.getElementById("backer-prediction-12").value; var backerPrediction13 = document.getElementById("backer-prediction-13").value; var backerPrediction14 = document.getElementById("backer-prediction-14").value; var backerPrediction15 = document.getElementById("backer-prediction-15").value; var backerPrediction16 = document.getElementById("backer-prediction-16").value; var backerPrediction17 = document.getElementById("backer-prediction-17").value; var backerPrediction18 = document.getElementById("backer-prediction-18").value; var backerPrediction19 = document.getElementById("backer-prediction-19").value; var backers = parseInt(backerPrediction1,10) + parseInt(backerPrediction2,10) + parseInt(backerPrediction3,10) + parseInt(backerPrediction4,10) + parseInt(backerPrediction5,10) + parseInt(backerPrediction6,10) + parseInt(backerPrediction7,10) + parseInt(backerPrediction8,10) + parseInt(backerPrediction9,10) + parseInt(backerPrediction10,10) + parseInt(backerPrediction11,10) + parseInt(backerPrediction12,10) + parseInt(backerPrediction13,10) + parseInt(backerPrediction14,10) + parseInt(backerPrediction15,10) + parseInt(backerPrediction16,10) + parseInt(backerPrediction17,10) + parseInt(backerPrediction18,10) + parseInt(backerPrediction19,10) ; document.getElementById("backer-prediction-answer").value = (backers); } &lt;/script&gt; </code></pre> <p>Thanks for your help!! :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload