Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    May 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arithmetic script...

    Hello,

    I am a math teacher and I always try to emphasise mental arithmetic since it is the one aspect of math that everyone uses in life no matter what they go on to do so mental arithmetic is a really valuable skill. I would like a javascript page which I can upload on our network for all the kids to access from their computers which will display a form where they can select various criteria (which operation: addition; subtraction; multiplication; division; squares and higher powers; square roots, cube roots and so on, the number of digits possibly specific values 3 x 3 digits or within a range between 1 and 3 digits for each number if that is possible so that the kids can completely cater it to their specific needs. I teach the various tricks and algorithms to help calculation so some of the kids can be pretty advanced so it would have to be really customisable. I would then want the random numbers generated based on the criteria and the answer calculated which can then be compared to what the kid enters in a textbox or some other input method.


    Sorry for the rambling way I have described this but I thought if I sacrifice concision for detail then it would help you to hopefully help me.


    Thanks for any assistance you may be able to provide.

    Regards,

    Mr. J.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,037
    Thanks
    203
    Thanked 2,539 Times in 2,517 Posts
    This forum is not a free coding service. As a general rule, the people helping out in this forum don't write code for others, but try to help with fixing code that doesn't work. You may perhaps get someone to write this script for you, but you'll be far more likely to get help if you have made a substantial effort and written some code yourself. Then someone here will almost certainly help you correct/improve your work.

    I suggest you do what you would do if your car or a domestic appliance broke down or you had toothache - pay a professional who understands what they are doing to fix it. You can post in the Web Projects section of this forum.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    May 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    This forum is not a free coding service. As a general rule, the people helping out in this forum don't write code for others, but try to help with fixing code that doesn't work. You may perhaps get someone to write this script for you, but you'll be far more likely to get help if you have made a substantial effort and written some code yourself. Then someone here will almost certainly help you correct/improve your work.

    I suggest you do what you would do if your car or a domestic appliance broke down or you had toothache - pay a professional who understands what they are doing to fix it. You can post in the Web Projects section of this forum.
    I wasn't asking anyone to just do it for me but I have no idea how to write javascript so I definitely don't know the best approach. I was hoping you could outline the approach and then I would try to write each function myself and if I couldn't do it, post it here.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,037
    Thanks
    203
    Thanked 2,539 Times in 2,517 Posts
    Quote Originally Posted by UsMathTeacher View Post
    I wasn't asking anyone to just do it for me but I have no idea how to write javascript so I definitely don't know the best approach. I was hoping you could outline the approach and then I would try to write each function myself and if I couldn't do it, post it here.
    That is not very sensible. How can you expect to write Javascript if you have no idea how to write Javascript? Or do you think that it is so trivial and simple that anyone can do it regardless of their complete lack of knowledge? Some would see that as rather insulting. And as silly as saying "I want to write a letter in French, but I do not know a word of that language".

    If you want to learn Javascript (which I have to say will take you rather longer than 10 minutes) you might start off with http://javascriptexample.net/
    Last edited by Philip M; 05-31-2014 at 02:03 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    624
    Thanks
    1
    Thanked 20 Times in 20 Posts
    I did a page a while back that does a bit of what you want. There are some external files referenced that I don't believe will have much negative effect. Start with this and write back to jalarie0@gmail.com if I can help you further:

    Code:
    <!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" xml:lang="en-US" lang="en-US">
      <head>
        <title>jalarie: Basic Math Practice</title>
        
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="Content-Script-Type" content="text/javascript" />
        <meta http-equiv="Content-Style-Type" content="text/css" />
        <meta http-equiv="Content-Language" content="en-US" />
        <meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.classify.org/safesurf/" l gen true for "http://spruce.flint.umich.edu/~jalarie/" r (SS~~000 1))' />
        <meta http-equiv="pics-Label" content='(pics-1.1 "http://www.icra.org/pics/vocabularyv03/" l gen true for "http://spruce.flint.umich.edu/~jalarie" r (n 0 s 0 v 0 l 0 oa 0 ob 0 oc 0 od 0 oe 0 of 0 og 0 oh 0 c 0)  gen true for "http://www.spruce.flint.umich.edu/~jalarie" r (n 0 s 0 v 0 l 0 oa 0 ob 0 oc 0 od 0 oe 0 of 0 og 0 oh 0 c 0))' />
        <link rel="meta" href="http://spruce.flint.umich.edu/~jalarie/labels.rdf" type="application/rdf+xml" title="ICRA labels" />
        <meta name="Author" content="James Alarie" />
        <meta name="description" content="Basic mathematics practice." />
        <meta name="keywords" content="basic,math,mathematics,practice,add,addition,subtract,subtraction,multiply,multiplication,divide,division" />
    
        <link rel="icon" href="favicon.ico" />
        <link rev="made" href="jaa_e.htm" />
        <link rel="start" href="index.html" type="text/html" title="James Alarie Home Page" />
        <link rel="prev" href="jaa_pfa.htm" title="Making Change" />
        
        <link rel="stylesheet" type="text/css" href="style1.css" />
        <style type="text/css">
          /*<![CDATA[*/
            .Column1 {
              float: left;
              width: 100px;
            }
            .Column2 {
              float: left;
              width: 120px;
            }
            .CountsR {
              background-color: lime;
              color: black;
            }
            .CountsW {
              background-color: pink;
              color: black;
            }
          /*]]>*/
        </style>
    
        <script type="text/javascript" src="head.js"></script>
    
        <script type="text/javascript">
          /*<![CDATA[*/
            function Init() {
              fA=document.forms[0];                     // abbreviation for addition
              fS=document.forms[1];                     // ...subtraction
              fM=document.forms[2];                     // ...multiplication
              fD=document.forms[3];                     // ...division
              ProbA=document.getElementById('ProblemA');
              ProbS=document.getElementById('ProblemS');
              ProbM=document.getElementById('ProblemM');
              ProbD=document.getElementById('ProblemD');
              TotR=document.getElementById('TotalR');
              TotW=document.getElementById('TotalW');
              TotR.innerHTML='&nbsp;0&nbsp;';
              TotW.innerHTML='&nbsp;0&nbsp;';
              SetupA();
              SetupS();
              SetupM();
              SetupD();
              StatsR=0;
              StatsW=0;
              return true;
            } // Init
            function CalcA() {
              if (fA.TotalA.value == A3) {
                StatsR++;
              } else {
                StatsW++;
                alert(A1+' + '+A2+' = '+A3);
              }
              TotR.innerHTML='&nbsp;'+StatsR+'&nbsp;';
              TotW.innerHTML='&nbsp;'+StatsW+'&nbsp;';
              SetupA();
              fA.TotalA.focus();
              fA.TotalA.select();
              return false;
            } // CalcA
            function CalcS() {
              if (fS.TotalS.value == S2) {
                StatsR++;
              } else {
                StatsW++;
                alert(S3+' - '+S1+' = '+S2);
              }
              TotR.innerHTML='&nbsp;'+StatsR+'&nbsp;';
              TotW.innerHTML='&nbsp;'+StatsW+'&nbsp;';
              SetupS();
              fS.TotalS.focus();
              fS.TotalS.select();
              return false;
            } // CalcS
            function CalcM() {
              if (fM.TotalM.value == M3) {
                StatsR++;
              } else {
                StatsW++;
                alert(M1+' * '+M2+' = '+M3);
              }
              TotR.innerHTML='&nbsp;'+StatsR+'&nbsp;';
              TotW.innerHTML='&nbsp;'+StatsW+'&nbsp;';
              SetupM();
              fM.TotalM.focus();
              fM.TotalM.select();
              return false;
            } // CalcM
            function CalcD() {
              if (fD.TotalD.value == D2) {
                StatsR++;
              } else {
                StatsW++;
                alert(D3+' / '+D1+' = '+D2);
              }
              TotR.innerHTML='&nbsp;'+StatsR+'&nbsp;';
              TotW.innerHTML='&nbsp;'+StatsW+'&nbsp;';
              SetupD();
              fD.TotalD.focus();
              fD.TotalD.select();
              return false;
            } // CalcD
            function SetupA() {
              MaxA=fA.MaximumA.options[fA.MaximumA.selectedIndex].value*1+1*1;
              A1=Math.floor(Math.random()*MaxA);
              A2=Math.floor(Math.random()*MaxA);
              A3=A1*1+A2*1;
              ProbA.innerHTML='&nbsp;'+A1+' + '+A2+'&nbsp;';
              fA.TotalA.value='?';
              return false;
            } // SetupA
            function SetupS() {
              MaxS=fS.MaximumS.options[fS.MaximumS.selectedIndex].value*1+1*1;
              S1=Math.floor(Math.random()*MaxS);
              S2=Math.floor(Math.random()*MaxS);
              S3=S1*1+S2*1;
              ProbS.innerHTML='&nbsp;'+S3+' - '+S1+'&nbsp;';
              fS.TotalS.value='?';
              return true;
            } // SetupS
            function SetupM() {
              MaxM=fM.MaximumM.options[fM.MaximumM.selectedIndex].value;
              M1=Math.floor(Math.random()*MaxM)+1;
              M2=Math.floor(Math.random()*MaxM)+1;
              M3=M1*M2;
              ProbM.innerHTML='&nbsp;'+M1+' * '+M2+'&nbsp;';
              fM.TotalM.value='?';
              return true;
            } // SetupM
            function SetupD() {
              MaxD=fD.MaximumD.options[fD.MaximumD.selectedIndex].value;
              D1=Math.floor(Math.random()*MaxD)+1;
              D2=Math.floor(Math.random()*MaxD)+1;
              D3=D1*D2;
              ProbD.innerHTML='&nbsp;'+D3+' / '+D1+'&nbsp;';
              fD.TotalD.value='?';
              return true;
            } // SetupD
          /*]]>*/
        </script>
    
      </head>
    
      <body class="body1"
          onload="Init();">
       <div id="Body">
    <!-- Page header -->
        <div id="Header">
          <a href="jaa_pfa.htm" title="Making Change">
            <img src="images/arrow121.gif" border="0" align="left" alt="prev. page" title="prev. page" width="32" height="32" /></a>
          <h1><a href="jaa_pfb.htm" target="_top" title="frameless version">
              Basic Math Practice</a></h1>
          &quot;And the king commanded, and they brought great stones, costly 
          stones, and hewed stones, to lay the foundation of the house.&quot;&nbsp; 
          1&nbsp;Kings&nbsp;5:17.
          <img src="http://counter.www.umich.edu/counter?link=http://spruce.flint.umich.edu/~jalarie/index.html" align="bottom" alt="#" title="#" width="1" height="1" />
          
          <script type="text/javascript" src="urhere.js"></script>
          <hr />
        </div>
      
    <!-- Main page content -->
        <div id="Content">
          <noscript>
            <p class="notice">
              You must have scripting enabled to make full use of this page.
            </p>
          </noscript>
          
          <script type="text/javascript">
            /*<![CDATA[*/
              if (!document.getElementById) {
                Out ='';
                Out+='<p class="notice">\n';
                Out+='  Your browser does not support the &quot;document.getElementById&quot; ';
                Out+='  function.&nbsp; Sorry.\n';
                Out+='<\/p>\n';
                document.write(Out);
              }
            /*]]>*/
          </script>
          
          <p>
            I feel that a good foundation in the basics of mathematics is needed 
            by anyone who is serious about counting blessings.&nbsp; The default 
            is to work with fairly small numbers; you may increase the limit if 
            you wish.&nbsp; These problems may seem fairly easy, but don't take 
            the exercises below too lightly; they are here to help.&nbsp; Practice 
            in a single area or jump around as much as you wish.
          </p>
          
          <form method="post" action="javascript:void(0);" onsubmit="return CalcA();">
           <div class="form">
            <div class="Column2">
              <b>Addition:</b>&nbsp; 
            </div>
            <label>maximum:&nbsp; 
              <select name="MaximumA">
                <option value="10" selected="selected">10</option>
                <option value="100">100</option>
                <option value="1000">1000</option>
              </select>
            </label>
            <br />
            <div class="indent">
              <span id="ProblemA" class="highlight Column1">&nbsp;</span>
              &nbsp;=&nbsp;
              <input type="text" size="5" name="TotalA" id="TotalA" value="?" onfocus="this.select();" />
            </div><!-- indent -->
           </div><!-- form -->
          </form>
            
          <form method="post" action="javascript:void(0);" onsubmit="return CalcS();">
           <div class="form">
            <br />
            <div class="Column2">
              <b>Subtraction:</b>&nbsp; 
            </div>
            <label>maximum:&nbsp; 
              <select name="MaximumS">
                <option value="10" selected="selected">10</option>
                <option value="100">100</option>
                <option value="1000">1000</option>
              </select>
            </label>
            <br />
            <div class="indent">
              <span id="ProblemS" class="highlight Column1">&nbsp;</span>
              &nbsp;=&nbsp;
              <input type="text" size="5" name="TotalS" id="TotalS" value="?" onfocus="this.select();" />
            </div><!-- indent -->
           </div><!-- form -->
          </form>
            
          <form method="post" action="javascript:void(0);" onsubmit="return CalcM();">
           <div class="form">
            <br />
            <div class="Column2">
              <b>Multiplication:</b>&nbsp; 
            </div>
            <label>maximum:&nbsp; 
              <select name="MaximumM">
                <option value="10" selected="selected">10</option>
                <option value="12">12</option>
                <option value="20">20</option>
              </select>
            </label>
            <br />
            <div class="indent">
              <span id="ProblemM" class="highlight Column1">&nbsp;</span>
              &nbsp;=&nbsp;
              <input type="text" size="5" name="TotalM" id="TotalM" value="?" onfocus="this.select();" />
            </div><!-- indent -->
           </div><!-- form -->
          </form>
            
          <form method="post" action="javascript:void(0);" onsubmit="return CalcD();">
           <div class="form">
            <br />
            <div class="Column2">
              <b>Division:</b>&nbsp; 
            </div>
            <label>maximum:&nbsp; 
              <select name="MaximumD">
                <option value="10" selected="selected">10</option>
                <option value="12">12</option>
                <option value="20">20</option>
              </select>
            </label>
            <br />
            <div class="indent">
              <span id="ProblemD" class="highlight Column1">&nbsp;</span>
              &nbsp;=&nbsp;
              <input type="text" size="5" name="TotalD" id="TotalD" value="?" onfocus="this.select();" />
            </div><!-- indent -->
           </div><!-- form -->
          </form>
          
          <br />
          Total right 
          <span id="TotalR" class="CountsR">&nbsp;0&nbsp;</span>
          and wrong 
          <span id="TotalW" class="CountsW">&nbsp;0&nbsp;</span>
          so far.
        </div>
      
    <!-- Page footer -->
        <div id="Footer">
          <br /><hr />
          <a href="jaa_pfa.htm" title="Making Change" class="SLD3-Box"><span>Back.</span></a>
          <div class="SLD3-Box"><span class="SLD3-Null">&nbsp;</span></div>
          <a href="jaa_a.htm" target="_top" title="Home Page" class="SLD3-Box"><span>Home.</span></a>
          <a href="jaa_b.htm" target="_top" title="Menu" class="SLD3-Box"><span>Menu.</span></a>
          <a href="jaa_zy.htm" title="Index" class="SLD3-Box"><span>Index.</span></a>
          <a href="jaa_zc.htm" title="Search" class="SLD3-Box"><span>Search.</span></a>
          <br class="SLD3" />
          <script type="text/javascript" src="footer.js"></script>
          <script type="text/javascript"> <!-- last updated -->
            /*<![CDATA[*/
              DocLMod('2008-03-15');                    // manually updated
            /*]]>*/
          </script>
          <noscript><p>Last update was by <a href="jaa_e.htm" title="E-mail / Guestbook">James Alarie</a>.</p></noscript>
        </div>
      
       </div>
      </body>
     
    </html>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •