Wenderson Lisboa 0 Posted July 1, 2019 Report Share Posted July 1, 2019 (edited) Boa noite amigos, mais uma vez venho solicitar a ajuda de vocês. Estou criando um aplicativo simples num site: preciso pegar um dado no input e exibi-lo numa TAG <p> usando o getElementById(). estou conseguindo mas na hora de mostrar o resultado ele simplesmente some rapidamente. Por favor me ajudem. <!DOCTYPE html> <html lang="pt-br"> <head> <meta charset="UTF-8"> <title>Document</title> <script> function imc(){ var alt = document.getElementById("altura").value; var pes = document.getElementById("peso").value; var mult = (alt * alt); var res = (pes / mult).toFixed(2); document.getElementById("resposta").innerHTML = `Seu IMC é : ${res}`; } </script> </head> <body> <form> <input type="text" id="peso"/><br> <input type="text" id="altura"/> <button onclick="imc()">Calcular</button> <p id="resposta"></p> </form> </body> </html> Edited July 21, 2019 by thoga31 GeSHi Link to post Share on other sites
Zex 8 Posted July 1, 2019 Report Share Posted July 1, 2019 Basta tirar <form> e </form> Link to post Share on other sites
Wenderson Lisboa 0 Posted July 1, 2019 Author Report Share Posted July 1, 2019 (edited) 21 minutos atrás, Zex disse: Basta tirar <form> e </form> Muito obrigado, estou iniciando do zero. Edited July 1, 2019 by Wenderson Lisboa Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now