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

361
Visualizações
i'm trying to make a dinamic checkbox in react using a state that combine multiple states but checkbox value is always "on" not even false or true

i have tried already to assign the checkbox checked=true so the btn works. i also tried to get to the value of the checkbox either from the e.target.value/checked but also no good came from it. if someone can help me i will be most greatful. thanks a lot here is the code:

here is the checkbox element:

  <label key={uuidv4()}>
            <span>{masters[index].free_text}</span>
            <input
              type="checkBox"
              name={masters[index].name}
              id={masters[index].name}
              checked={false}
              required={masters[index].required}
              // value={inputsAdContent.name?"true":"false"}
              onChange={handleChangeAdContent}
            />
          </label>

when the element is looking like this i get false at all times and it doesnt change

<label key={uuidv4()}>
            <span>{masters[index].free_text}</span>
            <input
              type="checkBox"
              name={masters[index].name}
              id={masters[index].name}
              
              required={masters[index].required}
              value={inputsAdContent.name==="true" ? "true" : "false"}
              onChange={handleChangeAdContent}
            />
          </label>

and here is the onChange:

 <label key={uuidv4()}>
            <span>{masters[index].free_text}</span>
            <input
              type="checkBox"
              name={masters[index].name}
              id={masters[index].name}
              
              required={masters[index].required}
              value={inputsAdContent.name==="true" ? "true" : "false"}
              onChange={handleChangeAdContent}
            />
          </label>

at the console i get this msg:

air_conditioner: "on"

this is the state i'm using:

const [inputsAdContent, setInputsAdContent] = useState({});

thank you all very much!!!

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