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

202
Vistas
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 Respuestas
Responde la pregunta

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