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

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

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 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