Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8251967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:24:39+00:00 2026-06-08T00:24:39+00:00

New to javascript! This works, but I have a lot more to do, and

  • 0

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 🙂

(stack wants me to write more before I submit, though I’m not sure what else to say)

<script>

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);
}
</script>

Thanks for your help!! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:24:41+00:00Added an answer on June 8, 2026 at 12:24 am

    I’d do it something like this:

    function apply() {
        var backers = 0;
        for (var i = 1; i < 20; ++i) {
            backers +=
                parseInt(document.getElementById("backer-prediction-" + i).value);
        }
        document.getElementById("backer-prediction-answer").value = backers;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im new at javascript and i can get this slider to work but not
New to javascript, but I'm sure this is easy. Unfortunately, most of the google
I have this Javascript code I inherited from another developer. I am very new
I am new to Javascript coding and have looked for this information in many
I'm really new to JavaScript and jQuery. My question is this. I have two
I apologize because this topic comes up a lot, but I have not been
Should this work? <script type=text/javascript> function load_i () { img = new Image(); img.onload
Ok im new to javascript and Unity so this is clearly a very noob
I'm very new to JavaScript in general so having trouble with this. Working with
I am very very new to JavaScript so sorry if this is really silly.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.