javascript calculation formula is not working

后端 未结 2 547
花落未央
花落未央 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);
    

提交回复
热议问题