Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

108
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda