<!-- 把하면代码加到<body>区域中 -->
<SCRIPT LANGUAGE="자바스크립트">
<!-- 시작
<!--
함수 findRoots() {
var ff = 문서.양식[
"쿼드"];
var a = ff.요소[
"a"].값;
var b = ff.요소[
"b"].값;
var c = ff.요소[
"c"].값;
if(a.length == 0 || a == "0") {
Alert("x^2의 계수는 0이 아닌 숫자여야 합니다.");
반품;
}
var addOf = -1*b;
var rootOf = b*b - 4*a*c;
var denomOf = 2*a;
ff.요소[
"be"].value = addOf;
ff.요소[
"루트"].value = rootOf;
ff.요소[
"denom"].value = denomOf;
var firstDivide = addOf / denomOf;
if(rootOf == 0) {
ff.요소[
"x1"].value = firstDivide;
ff.요소[
"x2"].value = "";
} else if(rootOf < 0) {
rootOf *= -1;
rootOf = Math.sqrt(rootOf);
루트오브 /= 데놈오브;
ff.요소[
"x1"].value = firstDivide + " + i" + rootOf;
ff.요소[
"x2"].value = firstDivide + " - i" + rootOf;
} else if(rootOf > 0) {
rootOf = Math.sqrt(rootOf);
루트오브 /= 데놈오프;
ff.요소[
"x1"].value = (firstDivide + rootOf);
ff.요소[
"x2"].value = (firstDivide - rootOf);
}
}
//-->
// 끝 -->
</script>
<form name="quad" onsubmit="return false;">
<p>请输入关数据
</p><p>
y = <input name="a" value="6" class="num" size=2>x<sup>2</sup> +
<input name="b" value="12" class="num" size=2>x +
<입력 이름="c" value="18" class="num" 크기=2>
</p><p>
<input type="button" value="计算" onclick="findRoots();">
</p>
<p>
<테이블 셀패딩=0 셀 간격=0 테두리=0>
<tr>
<td rowspan=3 정렬="오른쪽">
x<sub>1</sub>, x<sub>2</sub> =
</td>
<td 정렬="중앙">
<input name="be" class="num" size=2> + root(<input name="root" class="num" size=3>)
</td>
<td 행 범위=3>
=
</td>
<td rowspan=3 정렬="왼쪽">
<input name="x1" class="num" size="25"><br><input name="x2" class="num" size="25">
</td>
</tr>
<tr>
<TD>
<시간 너비="100%" 크기=1>
</td>
</tr>
<tr>
<td 정렬="중앙">
<입력 이름="denom" class="num" 크기=3>
</td></tr></table></p>
</form>