Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

311
Views
Estoy tratando de realizar un cálculo, devolver el resultado y mostrarlo en la misma página en node.js no puedo descifrar la última parte

Así que estoy tratando de realizar un cálculo en el nodo js y luego mostrar el resultado en

en el HTML principal, pero no puedo entender cómo. Todo lo demás está funcionando y listo, solo me falta la última parte. ¿Algunas ideas? Primer paso de la tarea Producto final de la tarea

Archivo JS:

 const express = require ("express"); const bodyParser = require ("body-parser"); const app = express(); app.use(bodyParser.urlencoded({extended: true})) app.use(express.static('public'));//to use css app.get("/", function(req, res){ res.sendFile(__dirname + "/bmi.html"); }); app.post("/", function(req, res){ var weight = parseFloat(req.body.weight); var height = parseFloat(req.body.height); var bmi = weight / Math.pow(height/100, 2); res.send("Your BMI Result is: " + bmi.toFixed(2)); }); app.listen(3000,function(){ console.log("Server running on port 3000"); });

Archivo HTML:

 <head> <link rel="stylesheet" type="text/css" href="/CSS/bmi.css"> <link href="https://fonts.googleapis.com/css?family=Noto+Sans" rel="stylesheet"> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>BMI checker</title> </head> <body> <div class="header"> <div class="wrapper"> <form action="/" method="post"> <h1>BMI calculator</h1> <p>Insert Your Age</p> <input type="number" id="age"> <p>Insert Weight in Kg</p> <input type="number" name="weight" id="weight"> <br> <p>Insert Height in cm</p> <input type="number" name="height" id="height"> <br> <button type="submit" id="calc">check</button> <p id="result"></p> </form> </div> </div> </body> </html>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!