Process form data with javascript and html

-3

I wanted to make a program that the user would send 3 notes and after pressing "Calculate", you would be redirected to a page that would appear to your average. Who could help me:

 function calcular()
        {
            var ac1 = parseInt(document.getElementById('ac1').value, 10);
            var ac2 = parseInt(document.getElementById('ac2').value, 10);
            var ac4 = parseInt(document.getElementById('ac4').value, 10);              
            var media = ((ac1*2)+(ac2*2)+ac4)/5;
            alert("Sua média desta etapa foi "+media);
        }
<html>
    <head>

        <style>
            input {
                margin-left: 100px;
                width: 45px;
            }
        </style>
    </head>
    <body>
        <form action="/teste1pag2" method="get">
                Digite sua nota da Ac1 aqui: <input type="number" id="ac1" min="0" max="10"> <br> 
                Digite sua nota da Ac2 aqui: <input type="number" id="ac2"> <br>
                Digite sua nota de participa&ccedil;&atilde;o aqui: 
                <input type="text" id="ac4" style="margin-left: 49px"> <br>
                <input type="submit" onblur="calcular()" value="Calcular!">
        </form>


    </body>
</html>
Thanks in advance!     
asked by anonymous 06.12.2018 / 15:34

1 answer

0

Using only JavaScript and HTML: functional example

Script

 function calcular()
        {
            var ac1 = parseInt(document.getElementById('ac1').value, 10);
            var ac2 = parseInt(document.getElementById('ac2').value, 10);
            var ac4 = parseInt(document.getElementById('ac4').value, 10);              
            var media = ((ac1*2)+(ac2*2)+ac4)/5;
            alert("Sua média desta etapa foi "+media);

            window.location.href = "pagina-destino.html?media="+media;
        }
                                    
06.12.2018 / 19:43