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

206
Visualizações
pass id and value to set of select input in react js

i have this set of select input that shows numbers on intail load on select filed and then i want to change value based on the option also i want to pass a id to the post api called user.id

{
  data.map((user) => (
    <select
      value={user.numberfromapi} // to show the number that is fecteched from api in intial load
      style={{ background: defaultcolor }}
      onChange={handleBackground(user.id ,value)} // i want to pass these 2 filds
    >
      <option value="1"> 1 </option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
    </select>
  ));
}

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can modify handleBackground to look like this.

const handleBackground = (userId) => ({ target }) => {
  let value = target.value;

  // you can use userId and value here.
}

Then in your JSX call handleBackground like this.

<select
  value={user.numberfromapi}
  style={{ background: defaultcolor }}
  onChange={handleBackground(user.id)}
>

Or do it the sloppy way like this.

<select
  value={user.numberfromapi}
  style={{ background: defaultcolor }}
  onChange={(event) => handleBackground(user.id, event.target.value)}
>
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