소수점 계산 관련하여

function merong() {
wr_5 = document.getElementById('wr_5');
wr_6 = document.getElementById('wr_6');
wr_28 = document.getElementById('wr_28');
wr_28.value = parseInt(wr_5.value) * parseInt(wr_6.value) * 2500;니다.
}
----------------------------------------------
자바 스크립트를 위와 같이 입력을 하고
------------------------------------------------

<B>가로</B>
<input type=text name=wr_5 id=wr_5 onchange="merong()" value="<?=$write[wr_5]?>" size="5" style="font-style:normal; font-weight:bold; font-size:10; color:rgb(255,153,0); text-decoration:blink; border-width:3px; border-style:solid;" maxlength="5" id="wr_5" itemname="556" />m&nbsp;X&nbsp;<b>세로</b>
<input type=text name="wr_6" id=wr_6 onchange="merong()" size="5" maxlength="5" itemname="555" value="<?=$write[wr_6]?>" style="font-style:normal; font-weight:bold; font-size:10; color:rgb(255,153,0); text-decoration:blink; border-width:3px; border-style:solid;" />m&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;&nbsp;&nbsp;&nbsp;
<input type=text name=wr_28 id=wr_28 size="15" onchange="merong3()" maxlength="5" itemname="557" value="<?=$write[wr_28]?>" style="font-style:normal; font-weight:bold; font-size:15; color:rgb(255,153,0); text-decoration:blink; border-width:3px; border-style:solid;" />원<br>

---------------------------------------------------------------------------------
이렇게 해서 입력을 받았는데요.

그런데...... 소수점 계산이 안되네요.

보여질때는 가로 "00" m * 세로 "00"m = "00"원
이렇게 출력이 되는 건데요.
가로 세로의 "00"을 입력시 소수점을 입력하면 정수만 즉 3.5 * 5.4를 계산하면
3*5*2500=37500 원이 나옵니다.
2500은 단가고요.

길이다 보니 소수점은 2자리수까지 가야 합니다. 어떻게 하면 계산을 할 수 있을 까요?
|

댓글 3개

wr_28.value = parseInt(wr_5.value) * parseInt(wr_6.value) * 2500;

parseInt 는 정수형으로 표현하라는 뜻입니다.
wr_28.value = wr_5.value * wr_6.value * 2500;
이렇게 수정하시면 될 듯합니다.
http://www.w3schools.com/jsref/jsref_parseFloat.asp
parseFloat()를 써 보세요.
아 그렇군요 답변감사합니다.
댓글을 작성하시려면 로그인이 필요합니다. 로그인

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
14년 전 조회 948
14년 전 조회 1,384
14년 전 조회 2,064
14년 전 조회 1,561
14년 전 조회 1,078
14년 전 조회 858
14년 전 조회 1,912
14년 전 조회 1,595
14년 전 조회 2,485
14년 전 조회 2,203
14년 전 조회 1,959
14년 전 조회 1,520
14년 전 조회 1,531
14년 전 조회 1,589
14년 전 조회 1,568
14년 전 조회 1,541
14년 전 조회 1,519
14년 전 조회 2,124
14년 전 조회 992
14년 전 조회 1,513
🐛 버그신고