<html> <head> <meta charset="utf-8"> </head> <body> <form> <input id="one"> <input id="two"> <button onclick="myFunction">Сравнить</button> </form> <p id="demo">Ответ</p> <script> function myFunction(){ var a, b, c; a = document.getElementById("one").value; b = document.getElementById("two").value; c = (a > b) ? a:b; document.getElementById("demo").innerHTML = c; } </script> </body> </html> 

    1 answer 1

     function myFunction() { var a, b, c; a = parseFloat(document.getElementById("one").value); b = parseFloat(document.getElementById("two").value); c = (a > b) ? a : b; document.getElementById("demo").innerHTML = c; } 
     <form> <input id="one"> <input id="two"> <button type="button" onclick="myFunction()">Сравнить</button> </form> <p id="demo">Ответ</p>