Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

75
Vistas
how to fix my Metric/Imperial unit conversion project in Javascript

i am trying to build a solo project in javascript. I am having trouble to display a function when an number input is submitted.

this is my HTML code

<header>
    <h1>Metric/Imperial unit conversion</h1>
    <form>
      <input type="number" name="input" id="input1">
    <input type="submit" onclick="meterFeet()">
    </form>
</header>
    <main>
      <h3>Length (Meter/Feet)</h3>
      <p class="p-l" id="p-l1" "></p>
      
    </main>

and this is my javascript code

let miucn = document.getElementById("input1");

function meterFeet() {
  document.getElementById("p-l1").textContent =
    miucn +
    " meters = " +
    (miucn * 3.281).toFixed(3) +
    " feet | " +
    miucn +
    " feet =" +
    (miucn / 3.281).toFixed(3) +
    " meters";
} 
about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

I made some small fixes in your code.

  1. change input type from submit to button
  2. put (document.getElementById("input1").value) inside the function
  3. parseInt() the input value

function meterFeet() {
  let miucn = parseInt(document.getElementById("input1").value);
  
  document.getElementById("p-l1").textContent =
    miucn +
    " meters = " +
    (miucn * 3.281).toFixed(3) +
    " feet | " +
    miucn +
    " feet =" +
    (miucn / 3.281).toFixed(3) +
    " meters";
  return false;
} 
<header>
    <h1>Metric/Imperial unit conversion</h1>
    <form>
      <input type="number" name="input" id="input1">
      <input type="button" onclick="meterFeet()" value="Submit">
    </form>
    </header>
    <main>
      <h3>Length (Meter/Feet)</h3>
      <p class="p-l" id="p-l1" "></p>
      
    </main>

about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda