간단한 계산기? 채택완료

1년 전 조회 2,070

978319507_1730276592.2987.png

 

이런식으로 A 에 숫자를 입력하면 B에 값이 나오게 하고싶은데(A x 0.5 = B)

이런 소스는 뭐라고 검색을 해야 할까요?

 

 

답변 2개

채택된 답변
+20 포인트

"auto calculate textbox value onchange"
"auto calculate textbox value onchange codepen"

 

Copy
<div style="margin:10px 0">
  <label for="price" style="display:block;margin-bottom:5px">A</label>
  <input type="text" id="price" placeholder="입력" onkeyup="calculateResult()">
</div>
<div style="margin:10px 0">
  <label for="result" style="display:block;margin-bottom:5px">B</label>
  <input type="text" id="result" readonly>
</div>

<script>
  function calculateResult() {
    let price = document.getElementById('price').value;
    let result = price * 0.5;  // 계산식: 입력값 × 0.5
    document.getElementById('result').value = result;
  }
</script>

 

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

사랑합니다

댓글을 작성하려면 로그인이 필요합니다.

답변감사합니다. 도움되었습니다.

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고