테스트 사이트 - 개발 중인 베타 버전입니다

간단한 계산기? 채택완료

한번잘해보자 1년 전 조회 1,617

http://sir.kr/data/editor/2410/978319507_1730276592.2987.png" width="400" />

 

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

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

 

 

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

답변 2개

채택된 답변
+20 포인트
1년 전

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

 

</p>

<p><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></p>

<p><script>

  function calculateResult() {

    let price = document.getElementById('price').value;

    let result = price * 0.5;  // 계산식: 입력값 × 0.5

    document.getElementById('result').value = result;

  }

</script></p>

<p>

 

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

답변에 대한 댓글 1개

한번잘해보자
1년 전
사랑합니다

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

g
1년 전

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

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

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

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

로그인