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

后端 未结 8 2040
一整个雨季
一整个雨季 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

提交回复
热议问题