my project is not executed in html

0

my problem is that when I run my project in visual studio 2017, it appears in the hello word browser and not the calculator that I programmed, I'm sure the code is right, just in case I show it, I tried to start a new project and paste it to the code but still in it.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title> Pagina Web SILV52 2017</title>
    <style>
        .body{
            background-image: url("https://i.imgur.com/eNHFe8V.h}jpg");
            background-position: center;
            background-attachment:fixed;
        }
        </style>
    <link rel="icon" href="c:\Users\joese\Documents\Icono\superthumb.ico" />
</head>
<body>
    class="body">
    <script type="text/javascript">
        function suma() {
            var num1, num2, total;
            var resul;

            num1 = number(document.getElementById("entrada1").value);
            num1 = number(document.getElementById("entrada2").value);
            total = num1 + num2;
            resul = "@ Resultado: " + total;

            document.getElementById("texto").innerHTML = result;

        }
    </script>
    <style>
        .texto {
            font-size: 50px;
            color: #fbf204;
            text-align: center;
        }


        .texto2 {
            background-color: #000000;
            margin: 10px 470px;
            border-style: inset;
            text-align: center;
            color: #00ff21;
            padding: 35px 10px;
        }

        .texto3 {
            color: #ffffff;
            text-indent: 435px;
        }

        .texto4 {
            color #ff0000;
            text-align: center;
        }
    </style>
    <p class="texto" SILV52 2017></p>
    <h2 class="texto4">Pagina simple y sencillita para todos los pelotudos</h2>
    <br />
    <p class="texto3">Ingrese Número<input type="number" id="entrada1" /> /</p>
    <p class="texto3">Ingrese Número<input type="number" id="entrada2" /> /</p>
    <style>
        .butto{
            background-color: #4CAF50;
            border: none;
            color:white;
            padding: 10px 32px;
            text-align:center;
            text-decoration: none;
            display:inline-block;
            margin: 10px 568px;
            cursor: pointer;

        }
    </style>
    <br />
    <button class="butto" onclick="Sumnar()">Calcular</button>
    <br />
    <h2 class="texto2" id="teto"></h2>

</body>
</html>
    
asked by Facundo Paez 06.12.2018 в 19:35
source

1 answer

1

Hello, your code should be something like this to work well:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title> Pagina Web SILV52 2017</title>
    <style>
        body{
            background-color:red;
            background-attachment:fixed;
        }
        </style>
    <link rel="icon" href="c:\Users\joese\Documents\Icono\superthumb.ico" />
</head>
<body class="body">
    <script type="text/javascript">
        function suma() {
            var num1, num2,resul,total;

            // num1 = number(document.getElementById("entrada1").value);
             num1 = parseInt(document.getElementById("entrada1").value);

            //num1 = number(document.getElementById("entrada2").value);
             num2 = parseInt(document.getElementById("entrada2").value);

            total = num1 + num2;
            resul = " Resultado: " + total;

            document.getElementById("texto").innerHTML = resul;

        }
    </script>
    <style>
        .texto {
            font-size: 50px;
            color: #fbf204;
            text-align: center;
        }


        .texto2 {
            background-color: #000000;
            margin: 10px 470px;
            border-style: inset;
            text-align: center;
            color: #00ff21;
            padding: 35px 10px;
        }

        .texto3 {
            color: #ffffff;
            text-indent: 435px;
        }

        .texto4 {
            color #ff0000;
            text-align: center;
        }
    </style>
    <p class="texto" SILV52 2017></p>
    <h2 class="texto4">Pagina simple y sencillita para todos los pelotudos</h2>
    <br />
    <p class="texto3">Ingrese Número<input type="number" id="entrada1" /> /</p>
    <p class="texto3">Ingrese Número<input type="number" id="entrada2" /> /</p>
    <style>
        .butto{
            background-color: #4CAF50;
            border: none;
            color:white;
            padding: 10px 32px;
            text-align:center;
            text-decoration: none;
            display:inline-block;
            margin: 10px 568px;
            cursor: pointer;

        }
    </style>
    <br />
    <button class="butto" onclick="suma()">Calcular</button>
    <br />
    <h2 class="texto2" id="texto"></h2>

</body>
</html>

The first error that I saw and it is very obvious is how you called the function you did it like this:

<button class="butto" onclick="Sumnar()">Calcular</button>

and it is assumed that your function is called sum and the other error was here:

<h2 class="texto2" id="teto"></h2>

Did you quibble on the ID and put it on it is it supposed to be text?

and the other mistake was here:

        document.getElementById("texto").innerHTML = result;

You used it and you defined it as result you should use result and it did not result (although it should be result) and the most common error is that you did not use the function: parseInt

to convert text to number.

I hope that you there served and helped :)

    
answered by 06.12.2018 в 19:59