합계를 구해야 하는데 왜 문자로 인식하는지 도와주세요.. 정보
합계를 구해야 하는데 왜 문자로 인식하는지 도와주세요..
본문
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>test</title>
<SCRIPT LANGUAGE="JavaScript">
function calc()
{
if (document.testform.chk.checked) {
document.testform.total.value = document.testform.a1.value +
document.testform.a2.value +
document.testform.a3.value +
document.testform.a4.value ;
document.testform.total.focus();
}
else
{
document.testform.total.value = ""
document.testform.total.blur();
}
}
</SCRIPT>
</head>
<body>
<FORM NAME="testform">
<br>
no 1: <input type="text" name="a1"><br>
no 2: <input type="text" name="a2"><br>
no 3: <input type="text" name="a3"><br>
no 4: <input type="text" name="a4"><br>
<br>
<input type="checkbox" name="chk" onClick="calc();">
합계: <input type="text" name="total">
</FORM>
</body>
</html>
<html>
<head>
<title>test</title>
<SCRIPT LANGUAGE="JavaScript">
function calc()
{
if (document.testform.chk.checked) {
document.testform.total.value = document.testform.a1.value +
document.testform.a2.value +
document.testform.a3.value +
document.testform.a4.value ;
document.testform.total.focus();
}
else
{
document.testform.total.value = ""
document.testform.total.blur();
}
}
</SCRIPT>
</head>
<body>
<FORM NAME="testform">
<br>
no 1: <input type="text" name="a1"><br>
no 2: <input type="text" name="a2"><br>
no 3: <input type="text" name="a3"><br>
no 4: <input type="text" name="a4"><br>
<br>
<input type="checkbox" name="chk" onClick="calc();">
합계: <input type="text" name="total">
</FORM>
</body>
</html>
댓글 전체
parseInt(document.testform.a1.value)
위처럼 바꿔줘야 합니다.
위처럼 바꿔줘야 합니다.