답변 2개 / 댓글 1개
채택된 답변
+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>
답변을 작성하려면 로그인이 필요합니다.
