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

  • Home
  • SEARCH
  • 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 6836997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:25:24+00:00 2026-05-26T23:25:24+00:00

I have a form with multiple textboxes and number of textboxes do change depending

  • 0

I have a form with multiple textboxes and number of textboxes do change depending on the values I retrieve from the database. What I am trying to do is multiply all values of textfields values so first I put them into an array and multiply them and send the answer to a textbox. But I cant seem to get the right answer.

For example when I have 3 textboxes and I enter 1 to each text box I should get 1x1x1 = 1 but I get answer as 3. An when I enter 2 in each text box I should get 2x2x2 = 8 but answer is 12.

My code is as follows:

Javascript Code:

function sumfrm(form){ 
  var totalOdds = 0;
  var odds = document.getElementsByTagName('input');
  var n;
  var i; //
for (i = 0; i < odds.length; ++i) {
  n = parseFloat(odds.item(i).value, 10);
    if (!isNaN(n)) {
       totalOdds += n*n;
   }
}
  • 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-05-26T23:25:25+00:00Added an answer on May 26, 2026 at 11:25 pm
    var totalOdds = 1; //initialize like this
    totalOdds = totalOdds * n // do this in your for loop
    

    should do the trick

    What you currently have for 1x1x1.

    totalOdds in the begining is 0

    After
    totalOdds += 1 * 1

    is 1

    Again after second time
    totalOdds += 1 * 1

    is 2

    and after third time it is 3

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get the values from multiple textboxes using JQuery. I'm a bit
I have a web form that has multiple ListBoxes, TextBoxes, DropDowns. If I put
I have a form with multiple textboxes with the same names. I want to
I have multiple textboxes in my form like txtTask0, txtTask1... txtTask12. so I want
I have multiple readonly textboxes like this <div id=box> <form method=post action=> <input type=text
I have a form with multiple textboxes on and a datatable, the datatable is
I have a form where I have lots of textboxes and all of them
I have a form with multiple fields that I'm validating (some with methods added
I have a form that has multiple fields, and for testing purposes is there
I have a form that will multiple Panel controls stacked on top of each

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.