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

88
Vistas
Why last checked checkbox keep it when i go to next questions? ReactJs

i am working on survey questioner and where i have multiple questions and when i check it one question checkbox it keep checked also next questions and so on , so how to now keep check when i go to next question on survey ?

here is json list of questions. Please help me i am struggling fro last few days

Here is what i did not far ?. This is checked function

const processInput = (e) => {
    const checked = e.target.checked;
    let detachedAnswers = answers;
    if (checked) {
      let index = detachedAnswers.findIndex((i) => i.question === show.id);
      // detachedAnswers[index] = e.target.checked;
      detachedAnswers[index].body.push(e.target.value);

      console.log(detachedAnswers);
      setAnswers(detachedAnswers);
    } else {
      const filtered = detachedAnswers[number].body.filter(
        (string) => string !== e.target.value
      );
      detachedAnswers[number].body = filtered;
      setAnswers(detachedAnswers);
    }
  };

here is the survey display using checkbox.

<div className="survey_option">
                {show?.choices?.split(",").map((c, index) => (
                  <div className="fix_lable" key={index + 1}>
                    <input
                      type="checkbox"
                      name="body"
                      id={c}
                      value={c}
                      // checked
                      // checked={c}
                      onChange={(e) => processInput(e, show.id)}
                    />
                    <label id={c} htmlFor={c}>
                      {c.split("-")[0]}
                    </label>
                  </div>
                ))}
              </div>
            </div>
about 4 years ago · Juan Pablo Isaza
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