DEV Community

tritanngo99
tritanngo99

Posted on

Error when calculating sum of 2 number in JS

I try write JS to calcalculating sum of 2 number in JS, but I get error !
This is mycode:

<!DOCTYPE html>
<HTML>

    <HEAD>
    <TITLE>Thay đổi giá trị của thuộc tính</TITLE>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    </HEAD>

    <BODY>
    <h2>Hãy nhập hai số và click vào nút Tính tổng</h2>
    <INPUT type="text" name="SoHang1" > +
    <INPUT type="text" name="SoHang2"> =
    <INPUT type="text" name="KetQua">
    <INPUT type="button" value="Sum"
    onClick="KetQua.value = parseFloat(SoHang1.value) + parseFloat(SoHang2.value)">
    </BODY>

    </HTML>
Enter fullscreen mode Exit fullscreen mode

So, I hope everyone can help me fix this error ! Thanks !

Top comments (0)