|
|
This page and the embedded script is an example downloaded from http://webdeveloper.earthweb.com/webjs/jsmath/item.php/645051 (June 2005). Have a look how the script is implemented.Quadratic Formula Solver-By: Elvin B. Gibson, Jr.-Quadratic Formula is a formula used to determine at what two points does quadratic function intercept the X axis. The formula consists of three variables A,B,C. If this form is reset, you can see the three, in the blank spaces where you put your values. (Feel free to modify, and remove this text & title. Just keep my name in the script, and this paragraph if you so happen to keep it. ;-)
The script looks like this: <html> <head> <title>Quadratic Formula</title> <script> //solves quadratic formula// //look for the removeable tag, to find out where to edit.// function quadFormula()
{
var a=eval(form.a.value) var b=eval(form.b.value) var c=eval(form.c.value) x1=(-b+(Math.sqrt(b*b-4*a*c)))/2*a; x2=(-b-(Math.sqrt(b*b-4*a*c)))/2*a; if (b*b-4*a*c<0)
{
alert("No Real Solutions\n-These Solutions are Imaginary!!!");
$note="i";
x1=(-b+(Math.sqrt(-(b*b-4*a*c))))/2*a;
x2=(-b-(Math.sqrt(-(b*b-4*a*c))))/2*a;
}
form.answer1.value=eval(x1); form.answer2.value=eval(x2); }
function clear1()
{
form.a.value=''
}
function clear2()
{
form.b.value=''
}
function clear3()
{
form.c.value=''
}
</script>
</head> <body> <center> <h1>Quadratic Formula Solver</h1> <h3>-By: Elvin B. Gibson, Jr.</h3> <form name="form"> <p><input type="text" name="a" onClick="clear1()" value="a" size="2"> x^2 + <input type="text" name="b" onClick="clear2()" value="b" size="2"> x + <input type="text" value="c" name="c" onClick="clear3()"> = 0<br> <input type="button" onClick="quadFormula()" value="Solve for X" /><br /><br /> <img src="quadform.bmp"> <br /><br />
<b>b(+)=x1</b><br />
<b>b (-)=x2</b><br /><br />
X1= <input type="text" name="answer1"> X2= <input type="text" name="answer2"> </p> <h3>And there's your solution!</h3> <button type="reset" name="cleardata">Reset</button> </form> </center> </body> </html> |
|