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

129
Vistas
Need to populate data of other filed based on the dropdown selection react formik

I have below form in react.

enter image description here

my requirement is once user select the sponsor address,address2,zipCode should be populated.

enter image description here

I have populated list for sponsor using below method.

 useEffect(()=>{
        fetchStatus();
    },[]);
    
    
    const fetchStatus = async ()=>{
       const {data}= await httpClient.get( config.resourceServerUrl+"/sponsors");
           setResult(data);
    }

this is my select code.

                                      <div>
                                        <select
                                            id="sponsor" 
                                            name="sponsor"
                                            className="form-control"
                                            placeholder="Sponsor"
                                            onChange={(e)=>populateData(e)}
                                        >
                                            <option value="">Please select the 
                                             sponsor</option>
                                          {
                                              result.map((res:any)=>
                                                  <option >{res.name}</option>
                                              )

                                          }
                                           </select> 
                                    </div>

I am calling below method on the onChange event.

const populateData=()=>{
    
}

can you help me the with logic for the code to populate the list. even small suggestion will be really helpful.

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

0

When the populateData func is envoked try something like

firstly have some local state or redux state

const [data, setData] = useState({
address: '',
address2: '',
zipCode: '',
})

const populateData = () => {
 const dataToAdd = getsomeData(() => ({
address: 'Some address',
address2: 'something else',
zipCode: 'ZIP_CODE',
}))
 
setData(dataToAdd)

}

then have the values passed to the inputs and either have them as controlled inputs or you will have to update the formData in a similar way

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