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

81
Vistas
2 name and value attribute in one select

I have database that have users ID,name,shopCode.

what I am looking for is when the user select the supervisor, also will get shopCode value for selected supervisor. Is there way to have 2 name and 2 value attribute in select tag ?

  <select name="supervisor_ID shopCode_ID" id="supervisor_ID shopCode_ID">
    <% for (const i in supervisor) { %>
      <option value="<%= supervisor[i].id supervisor[i].shopCode%>"> <%= supervisor[i].name %> </option>
      <% } %>
 
  </select>
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can use data attribute for additional information like below

<select id="select">
  <option value="1" data-foo="dogs">this</option>
  <option value="2" data-foo="cats">that</option>
  <option value="3" data-foo="gerbils">other</option>
</select>
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can set both the values with a seperator and then split up the seperator to get the values. For example:

let selectbox = document.querySelector('select');
selectbox.addEventListener('change', function(e) {
  let val = this.value.split(':');
  alert(`Supervisor ID: ${val[0]} Shopcode ID: ${val[1]}`);
})
 <select name="supervisor_ID shopcode_ID" id="supervisor_ID shopcode_ID">
     <option selected disabled>Select a supervisor</option>
     <option value="505:1">Mr. Supervisor 505</option>
     <option value="506:121">Mr. Supervisor 506</option>
     <option value="505:134">Mr. Supervisor 505</option>
 </select>

you can then use javascript to get the values.

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