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

108
Visualizações
Selecting values from multiple select option box - Jquery

I am trying to select values in a multiple select option box. When i run my current code below, no item is selected in the option box but when i do parseInt(value) it only selects just the first option.

When i console.log(selected), it returns 4,5. How can insert 4,5 into $("#edit-items") to make it select both values in the option box.

PS: Sorry for my english

JS

 var selected = $(this).attr('data-items');  returns 4,5
 items = parseInt(selected)
 $("#edit-items").val([items]);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

parseInt() will only parse the first integer from 4,5. If you want to get all the intgers as an array, split the string and call parseInt() on each array element.

items = selected.split(',').map(str => parseInt(str));
$("#edit-items").val(items);
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