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

171
Visualizações
How to properly pass variables in an array from a form using Javascript jquery

when I run the code below it works fine

<script>

var key_values =[79, 129, 183, 128, 66];
const secret_keys = new Uint8Array(key_values);
console.log(secret_keys);

//Uint8Array(64) [ 79, 129, 183, 128, 66 ]

</script>

Here is my issue:

when I pass the key_values variable into an arrays from form inputs. it does not display any value in the console.

This is what it displayed in the console Uint8Array [0] instead of Uint8Array(64) [ 79, 129, 183, 128, 66 ]

here is the code.

<script>
            $(function () {
                $('#save').click(function () {
                    
// inputted form values 79, 129, 183, 128, 66

var key_values = $('#my_keys').val();

const secret_keys = new Uint8Array([key_values]);
console.log(secret_keys);

//Uint8Array [0]



    });
            });
</script>
<input type="text" id="my_keys" value="79, 129, 183, 128, 66">

                    <input type="button" id="save" value="save" />
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need to parse the string as an array before passing it to the constructor or just split by comma to get an array.

const secret_keys = new Uint8Array(key_values.split(","));
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