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

105
Vistas
How to create a html page with an input and it tells the object properties of the input?

I want to create a html page in which there is an input. For eg I am entering an Input Mango, it alerts properties of the object. for eg. in case of mango -

color = 'Yello'
tasste = 'sweet'
price = 30

Can you please help me out doing this.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can simply define the data json to a var and extract it's value whenever you user has entered any value in the input box by using the EventListener ....

You can try:

// Add more items as per your choice in it

data = {
  "mango": {
    "color": "Yello",
    "tasste": "sweet",
    "price": 30
  },
  "apple": {
    "color": "Red",
    "tasste": "sweet",
    "price": 40
  }
}

document.getElementById("input").addEventListener('input', function(evt) {
  if (data[this.value]) {
    document.getElementById("details").innerHTML = `Color : ${data[this.value]['color']}<br>
    Taste : ${data[this.value]['tasste']}<br>
    Price : ${data[this.value]['price']}`;
  } else {
    document.getElementById("details").innerHTML = "Invalid Input.<br>Please enter a valid value";
  }
});
<input type="text" id="input">
<div id="details"></div>

about 4 years ago · Juan Pablo Isaza 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