Script Categories













Calculators >>> Quadratic.

Solves quadratic equations for inputted coefficients. Answers can be either real or complex.

Quadratic Equation:
Ax2 + Bx + C = 0
A =
B =
C =
X1 =
X2 =

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function quad(form) {
a=eval(form.a.value);
b=eval(form.b.value);
c=eval(form.c.value);
x1=-b/2/a+Math.pow(Math.pow(b,2)-4*a*c,0.5)/2/a;
x2=-b/2/a-Math.pow(Math.pow(b,2)-4*a*c,0.5)/2/a;
form.x1.value = x1;
form.x2.value = x2;
if (form.x1.value == "NaN") form.x1.value="Imag.!";
if (form.x2.value == "NaN") form.x2.value="Imag.!";
}
// End -->
</script>
<form name=form>
<table border=1 cellpadding=2>
<tr>
<td
colspan=2 align=center><b>Quadratic Equation:<br>Ax<sup>2</sup> + Bx + C = 0</b></td>
</tr>
<tr>
<td>
<center><table border=1 width=100% cellpadding=2>
<tr>
<td
align=center><b>A = </b></td>
<td
align=center><input type=text size=6 name="a"></td>
</tr>
<tr>
<td
align=center><b>B = </b></td>
<td
align=center><input type=text size=6 name="b"></td>
</tr>
<tr>
<td
align=center><b>C = </b></td>
<td
align=center><input type=text size=6 name="c"></td>
</tr>
</table>
</td>
<td>
<center><table border=1 width=100% cellpadding=2>
<tr>
<td
colspan=2 align=center>
<input type=button value="Solve" onClick="quad(this.form)"></td>
</tr>
<tr>
<td
align=center><b>X1 = </b></td>
<td
align=center><input type=text size=6 name="x1"></td>
</tr>
<tr>
<td
align=center><b>X2 = </b></td>
<td
align=center><input type=text size=6 name="x2"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).

Bitcoin Dice Site . loansangel bbb


©