Making a button read the functions

Asked

Viewed 59 times

0

I am beginner in programming and I need help with the function of a button, I do not know how to make this button "read" the age values, the idea of the site is to enter the information to see if the person requires retirement or not

this is a test function so there is quite a lot missing in this code like the var name

         function verificaAposentadoria()
            {



            var idade = document.getElementById("idade").value;
            var trabalho = document.getElementById("trabalho").value;
            var resultado = document.getElementById("resultado");

                idade = parseInt(idade)
                trabalho = parseFloat(trabalho)
                resultado = parseInt(resultado)
            var saida = "Olá, "+nome+", seu tempo é "+trabalho;

            document.getElementById("resultado").innerHTML = saida;




            if ("trabalho">=60)  
            alert ("Você pode se aposentar")
            }






            </script>
  • There’s still an error in the code: if ("trabalho">=60)... should be if (trabalho>=60)... trabalho is a variable and not a string. Just remove the quotes.

1 answer

0


In Html you can do

<button type='button' onclick="verificaAposentadoria()"> Verificar </button>
  • 1

    Many thanks friend : ) helped a lot

  • It was nothing @Calado ! Good luck in your studies :D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.