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

194
Visualizações
Chrome forgets to send form element

I have a form with two select inputs that are used to pick values from a list using some simple jquery script. Think of it as a lightweight picklist.

For the sake of testing I have reduced everything to the bare minimum. The form now only contains one text input for sanity, and the two selects for showing and picking data. Basically it comes down to this:

<form>
    <input name="name" type="text">
    <select></select>                     <!-- contains search results -->
    <select name="members[]"></select>    <!-- contains the current selection -->
    <button type="submit">
</form>

The javascript attaches an event listener to the select elements in order to allow the user to select and deselect values, which are moved from one to the other.

On submit, javascript selects all values in members[] so that they will be sent in the POST request.

With Firefox and Safari, everything works. Submitting the form sends the auto-selected values from members[] to the server. Any combination of selecting, deselecting, works fine.

With Chrome (102.0.5005.115) however, strange behavior is observed:

  • nothing changes: all values from members[] are POSTed
  • 1 value added: all values from members[] are POSTed
  • 1 value removed: no values from members[] are POSTed
  • 1 value removed and re-added: only that value from members[] is POSTed
  • 1 value added and 1 removed: no values from members[] are POSTed

It seems that manipulating the contents of the members[] select box sometimes confuses Chrome and makes it forget to send the values across.

I have a JSFiddle where this can be tested. The form is not submitted in this test but the serialization is logged to console and shows the described erroneous behavior.

https://jsfiddle.net/y54fq7L6/1/

Has anyone seen this happen? Am I doing something wrong?

about 4 years ago · Juan Pablo Isaza
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