Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Online Javascript Editor

<html>
    <head>
        <title>Matematica basica</title>
    </head>
    <body>
        SUMA: <input type="text" id="n1"> + 
        <input type="text" id="n2"> = 
        <input type="text" id="res">
        <input type="button" value="SUMA" onclick="suma()"><br><br>
        RESTA: <input type="text" id="n1r"> -
        <input type="text" id="n2r"> =
        <input type="text" id="res2">
        <input type="button" value="RESTA" onclick="resta()"><br><br>
        MULTIPLICAR: <input type="text" id="n1m"> x 
        <input type="text" id="n2m"> =
        <input type="text" id="res3">
        <input type="button" value="MULTIPLICAR" onclick="multiplicar()"><br><br>
        DIVICION: <input type="text" id="n1d"> /
        <input type="text" id="n2d"> =
        <input type="text" id="res4">
        <input type="button" value="DIVIDIR" onclick="dividir()">
        
        
        
        
        <script>
            function suma(){
                var num1=Number(document.getElementById('n1').value);
                var num2=Number(document.getElementById('n2').value);
                var res=num1+num2;
                document.getElementById('res').value=res;
            }
            
        </script>
        <script>
            function resta(){
                var num1r=Number(document.getElementById('n1r').value);
                var num2r=Number(document.getElementById('n2r').value);
                var res2=num1r-num2r;
                document.getElementById('res2').value=res2;
            }
        </script>
        <script>
            function multiplicar(){
                var num1m=Number(document.getElementById('n1m').value);
                var num2m=Number(document.getElementById('n2m').value);
                var res3=num1m*num2m;
                document.getElementById('res3').value=res3;
            }
        </script>
        <script>
            function dividir(){
                var num1d=Number(document.getElementById('n1d').value);
                var num2d=Number(document.getElementById('n2d').value);
                var res4=num1d/num2d;
                document.getElementById('res4').value=res4;
            }
        </script>
        
    </body>
</html>

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.