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
manipulating SerializeArray in jquery

hey guys I've been trying to use javascript/jquery for getting an array of name and values of an element. I've used serialize Array function it works fine but, i need more than that please look into the code below.

$(document).ready(function(){
  var maps = {};
  $("#submitt").click(function(){
    var x = $("#details").serializeArray();
    // x.push({"name" : "event_id", "value" : 22});
    console.log(x);
    });
    });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form action="" id = "details">  
  <div class = "general" name = 'GENERAL'>
    <input type="checkbox" name ="email">
    <input type="checkbox" name ="phone">
    <input type="checkbox" name ="push">
  </div>
  <div class = "general" name = 'MEETING'>
    <input type="checkbox" name ="email">
    <input type="checkbox" name ="phone">
    <input type="checkbox" name ="push">
  </div>
</form>
<button type = "submit" id= "submitt">submit</button>

it returns all the inputs without any identification. I need it to be like :

{
GENERAL : {
    email : on,
    phone : on,
    push : on
},
MEETING : {
    email : on,
    phone : on,
    push : on
}

just like a multi-dimensional array in php. Is there any other way to get the required results? please help me out.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

just try like bellow code <input type="checkbox" name ="GENERAL[email]">

<form action="" id = "details">  
 <div class = "general" >
   <input type="checkbox" name ="GENERAL[email]">
   <input type="checkbox" name ="GENERAL[phone]">
   <input type="checkbox" name ="GENERAL[push]">
 </div>
 <div class = "general" >
   <input type="checkbox" name ="MEETING[email]">
   <input type="checkbox" name ="MEETING[phone]">
   <input type="checkbox" name ="MEETING[push]">
 </div>
<button type = "submit" id= "submitt">submit</button>
</form>```
 
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