• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
JavaScriptSource

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Browse Snippets
    • Addon
    • Ajax
    • Buttons
    • Cookies
    • CSS
    • Featured
    • Forms
    • Games
    • Generators
    • Image Effects
    • Math Related
    • Miscellaneous
    • Multimedia
    • Navigation
    • Page Details
    • Passwords
    • Text Effects
    • Time & Date
    • User Details
Home / Generators / Linear Equation Generator

Linear Equation Generator

Linear Equation Generator

This Linear Equation generator asks you to find the relationship between X and Y. This is a straight line formula in the form of Y=MX+B where M is the slope and B is the y-intersect.

X 1 2 3 4 5
Y          

Y = X +

 

  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
<!– This script and many more are available free online at –>

<!– The JavaScript Source!! http://javascriptsource.com –>

<!– Original:  Benjamin M. Joffe ([email protected]) –>

<!– 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>
<BODY onLoad="domath()">
<!– This script and many more are available free online at –>

<!– The JavaScript Source!! http://javascriptsource.com –>

<!– Original:  Benjamin M. Joffe ([email protected]) –>

<!– 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=”https://javascriptsource.com”>The JavaScript Source</a></font>

</center><p>

Generators

Related Snippets:

  • Generate a random hexadecimal color code
  • Range generator
  • Drop Down Menu Generator
  • How To Generate A Random String In JavaScript

Primary Sidebar

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2025 JavaScriptSource.com

  • About
  • Privacy Policy
  • FAQ
  • Jobs For Developers