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

222
Visualizações
Display input based on another input value in Reactjs

I am making a react app with form data from JSON.

Implementation wise completed but I am stuck with an issue in making an input box which depend on another.

Things Tried:

  const config: { [key: string]: any } = {
    defaultHidden: [
      "dose",
      "reason",
      "moreDetails",
      "doseOneDetails",
      "doseTwoDetails"
    ],

    vaccinated: {
      vaccinated: ["reason", "doseOneDetails", "doseTwoDetails"],
      not_vaccinated: ["dose", "doseOneDetails", "doseTwoDetails"]
    }
  };

As the data is retrieved from JSON, I have made a configuration variable to make the defualt hidden and hidden on selection of particular fields.

Issue: (Both happen after selecting the dose from select box)

-> Unable to display the dose one details input box after selecting dose one.

-> Unable to display the dose two details input box after selecting dose two.

The above issue happens because of vaccinated: ["reason", "doseOneDetails", "doseTwoDetails"], as it has both the fields under hidden. But I am stuck how to display the respective input field.

Requirement:

Scenario 1:

User selects vaccinated as an option from first select box, then the select box with data as Dose One and Dose Two appears. Then if user select any of the dose then he need to add details on that respective dose.

Scenario 1: (Working Now)

User selects Not Vaccinated as an option from first select box, then the reason select box will be displayed.

Working Example:

Edit antd typescript (forked)

The current configuration takes only one level but how can we handle multi level (Input depending on other and so on) like the above scenario?

Kindly help me to get out of this huddle as I am stuck with this for long. Thanks in advance.

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