javascript calculation formula is not working

后端 未结 2 530
花落未央
花落未央 2021-01-24 20:28

I have following JavaScript function to make some calculation with textboxes but when I call this function on textbox the it doesn\'t works. Here is my JS code

U

相关标签:
2条回答
  • 2021-01-24 20:50

    Your variables aren't numbers. They are strings, so addition just concatenates them together.

    Cast them to integers:

    var pkrusd = parseInt(document.getElementById('txtpkrusd').value, 10);
    

    Or floats:

    var pkrusd = parseFloat(document.getElementById('txtpkrusd').value);
    
    0 讨论(0)
  • 2021-01-24 21:01

    Check your id's in the script. You need to use txtRatelb instead of txtratelb. They are case-sensitive.

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