![](/img/trans.png)
[英]How to update the value in one text box based on the value entered in another text box?
[英]Automatically display value in a text box based on the value entered in another text box using javascript
我有3個文本框,分別是textbox1
, textbox2
和textbox3
。
如果我為textbox1
輸入一個數值,則textbox2
和textbox3
自動textbox2
顯示值textbox1*25
和textbox*75
。
Textbox2和textbox3
不可編輯,並且應處於顯示模式。
誰能幫助我使用JavaScript查找解決方案。
在此先感謝,Amith
在三個元素(如id =“ textbox1”)中需要一個id,在textbox1元素中,您需要一個事件(如onChange =“ my_func()”),因此每次更改值時,它都會跳轉到該函數:
然后,您需要以下javascript函數:
<script>
function my_func() {
document.getElementById("textbox2").innerHTML=document.getElementById("textbox1").value*25;
document.getElementById("textbox3").innerHTML=document.getElementById("textbox1").value*75;
}
</script>
即使我們不是代碼工廠,也請嘗試以下操作: myExample
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.