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 7596325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:53:32+00:00 2026-05-30T21:53:32+00:00

<!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8 /> <title>MultipleOf</title> <script> var sales = new

  • 0
    <!DOCTYPE html>
    <html lang="en">
<head>
    <meta charset="utf-8" />
    <title>MultipleOf</title>
    <script>
                    var sales = new Array(9); //array for keeping sales numbers
        var pay = ["200-299","300-399","400-499","500-599","600-699","700-799","800-899","900-999","1000 and over"];
        var tally = new Array(9); //array for keeping statistics
        result=""; //for table creation
        temp="";

        for(i=0; i<9; i++){ //initialize empty arrays of numbers
            tally[i] =0;
            sales[i] =0;
        }

        function start(){  //button to launch everything
            var button = document.getElementById("clickButton");
            button.addEventListener("click", giveResult, false);
        }
        function giveResult(){ //is supposed to calculate sales and add one to the tally the position which the sale belongs.
            for(var i=0; i<9; i++){
                temp="e"+i;
                sales[i]= parseInt(document.getElementById(temp)); //Grab info from form (currently from first field)
                sales[i]=paid(sales[i]); //calculate pay for sales made and overwrite sales amount
                var placement = decide(sales[i]); //decide which statistic to increment according to amount paid
                tally[placement]= tally[placement]+1;  //increment statistic
            }
            var result = document.getElementById("result");
            temp = display(result);
            result.innerHTML = temp;
        }


        function paid(salesAmount){
            return 200+(salesAmount*0.09);
        }
        function decide(amountPaid){
            if(amountPaid>1000)
                return 8;
            else if(amountPaid>900)
                return 7;
            else if(amountPaid>800)
                return 6;
            else if(amountPaid>700)
                return 5;
            else if(amountPaid>600)
                return 4;
            else if(amountPaid>500)
                return 3;
            else if(amountPaid>400)
                return 2;
            else if(amountPaid>300)
                return 1;
            if(amountPaid>=200)
                return 0;
            else 
                return -1;
        }

        function display(value){
            value = "<table>"
            for(var i=0;i<pay.length; i++){
                value = value + "<tr><td>" + pay[i] + "</td>" + "<td>" + tally[i] + "</td>" ;  
            }
            value = value + "</table>";
            return value;
        }


        window.addEventListener("load",start,false);
    </script>
</head>
<body>
    <form action="#">
        <p><label>Enter Employee Sales for the week:</label></p>
            <p>Employee 1:<input id="e1" type="number" value="0"></p>
            <p>Employee 2:<input id="e2" type="number" value="0"></p>
            <p>Employee 3:<input id="e3" type="number" value="0"></p>
            <p>Employee 4:<input id="e4" type="number" value="0"></p>
            <p>Employee 5:<input id="e5" type="number" value="0"></p>
            <p>Employee 6:<input id="e6" type="number" value="0"></p>
            <p>Employee 7:<input id="e7" type="number" value="0"></p>
            <p>Employee 8:<input id="e8" type="number" value="0"></p>
            <p>Employee 9:<input id="e9" type="number" value="0"></p>
            <p><input id = "clickButton" type="button" value = "Calculate"></p>
    </form>
    <p id = "result"></p>
        <footer>
            <p>
            </p>
        </footer>
</body>

I am hoping to input sales numbers into a form, then calculate the earnings for each employee using the function paid(), and then to take those earnings and sort them into a table with ranges such as defined by the pay array.

The problem is I am not sure what I am doing wrong, is it my paid() function that is messing up the counters?

The tally array is not being updated correctly and I am not sure why.

  • 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-30T21:53:33+00:00Added an answer on May 30, 2026 at 9:53 pm

    sales[i]= parseInt(document.getElementById(temp)); //Grab info from
    form (currently from first field)

    Try parseInt(document.getElementById(temp).value, 10) instead.

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

Sidebar

Related Questions

With some HTML like this: <!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <title>JS Bin</title>
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd> <html> <head> <title>Hijack Example</title> <script type=text/javascript src=./jquery-1.2.1.js></script>
See example: <!DOCTYPE html> <html> <head> <title>language</title> <script type=text/javascript src=http://www.google.com/jsapi> </script> </head> <body> <div
I have the following html code <!DOCTYPE html> <html lang=en> <head> <meta name=viewport content=width=device-width;
This is my HTML: <!DOCTYPE html> <html> <head> <script> function run(){ var div =
<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd> <html xmlns=http://www.w3.org/1999/xhtml> <head> <meta http-equiv=Content-Type content=text/html;
<!DOCTYPE HTML PUBLIC -//IETF//DTD HTML//EN> <html> <head> <title>How to Write a Good Report</title> <style
<!DOCTYPE HTML PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd><html xmlns=http://www.w3.org/1999/xhtml> <head> <title>Test</title> <style type=text/css media=screen>
<!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Strict//EN http://www.w3.org/TR/html4/strict.dtd> <html> <head> <meta http-equiv=Content-Type content=text/html; charset=UTF-8>
<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> <html xmlns=http://www.w3.org/1999/xhtml> <head> <meta http-equiv=Content-Type content=text/html;

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.