topical media & game development

talk show tell print

#javascript-generator-linear-equation.htm / htm



  
  <!-- THREE STEPS TO INSTALL LINEAR EQUATION GENERATOR:
  
    1.  Copy the coding into the HEAD of your HTML document
  
    2.  Add the onLoad event handler into the BODY tag
  
    3.  Put the last coding into the BODY of your HTML document  -->
  
  <!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->
  
  <HEAD>
  
  <!-- This script and many more are available free online at -->
  
  <!-- The JavaScript Source!! http://javascript.internet.com -->
  
  <!-- Original:  Benjamin M. Joffe (ben@joffe.com) -->
  
  <!-- Web Site:  http://www.rollingtank.com/benjoffe/ -->
  
  <script>
  
  var gradient=0;
  
  var intersect=0;
  
  function domath(){
  
  gradient=0;
  
  intersect=0;
  
  while ((gradient==0 || gradient==1)) gradient=Math.round(Math.random()*60- 30)/2;
  
  while (intersect==0) intersect=Math.round(Math.random()*60- 30)/2;
  
  xone.innerHTML=gradient+intersect;
  
  xtwo.innerHTML=2*gradient+intersect;
  
  xthree.innerHTML=3*gradient+intersect;
  
  xfour.innerHTML=4*gradient+intersect;
  
  xfive.innerHTML=5*gradient+intersect;
  
  }
  
  function checkmath(){
  
  if (gradientanswer.value==gradient & intersectanswer.value==intersect) {correct.innerHTML="Correct"}
  
  else {correct.innerHTML="Incorrect";}
  
  }
  
  function revert(){correct.innerHTML=""}
  
  </script>
  
  </HEAD>
  
  <!-- STEP TWO: Insert the onLoad event handler into your BODY tag  -->
  
  <BODY onLoad="domath()">
  
  <!-- STEP THREE: Copy this code into the BODY of your HTML document  -->
  
  <!-- This script and many more are available free online at -->
  
  <!-- The JavaScript Source!! http://javascript.internet.com -->
  
  <!-- Original:  Benjamin M. Joffe (ben@joffe.com) -->
  
  <!-- Web Site:  http://www.rollingtank.com/benjoffe/ -->
  
  <table class=main border="0" cellpadding="0" cellspacing="0" width="400" height="350">
  
    <tr>
  
      <td align="center">
  
  <p style=font-size:14pt;font-weight:bold;>Maths Quiz Two</p>
  
  <p>This maths question generator asks you to find the relationship between X and
  
  Y. This is a linear  fucntion in the form of Y=MX+B where M is the gradient
  
  and B is the y-intersect.</p>
  
  <p><input type="button" value="New Question" onclick=domath() class="form"></p>
  
  <table border="1" cellpadding="5" cellspacing="0" bgcolor="#003366">
  
    <tr>
  
      <td>X</td>
  
      <td align="center">1</td>
  
      <td align="center">2</td>
  
      <td align="center">3</td>
  
      <td align="center">4</td>
  
      <td align="center">5</td>
  
    </tr>
  
    <tr>
  
      <td>Y</td>
  
      <td id=xone> </td>
  
      <td id=xtwo> </td>
  
      <td id=xthree> </td>
  
      <td id=xfour> </td>
  
      <td id=xfive> </td>
  
    </tr>
  
  </table>
  
  <p>Y = <input type="text" size="4" maxlength=5 onkeydown=revert() id=gradientanswer class="form">
  
  X + <input type="text" size="5" maxlength=5 onkeydown=revert() id=intersectanswer class="form">
  
  <input type="button" onclick=checkmath() value=" OK " class="form"></p>
  
  <p id="correct"> </p>
  
  </td>
  
    </tr>
  
  </table>
  
  <p><center>
  
  <font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
  
  by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
  
  </center><p>
  
  <!-- Script Size:  3.24 KB -->
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.