Add two textbox values and display the sum in a third textbox automatically

后端 未结 8 2006
一整个雨季
一整个雨季 2020-12-18 00:43

I have assigned a task to add two textbox values.I want the result of addition to appear in the 3rd textbox,as soon as enter the values in the first two textboxes,without pr

相关标签:
8条回答
  • 2020-12-18 01:18

    Since eval("3+2")=5 ,you can use it as following :

    byId=(id)=>document.getElementById(id); 
    byId('txt3').value=eval(`${byId('txt1').value}+${byId('txt2').value}`)
    

    By that, you don't need parseInt

    0 讨论(0)
  • 2020-12-18 01:20

    Well, base on your code, you would put onkeyup=sum() in each text box txt1 and txt2

    0 讨论(0)
提交回复
热议问题