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

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

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 Relatório

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