javascript - I need an array of selected checkboxes -


javascript code:

var simvalue = $('input[name="simnamecbx"]:checked').each(function() {         var sim_name=this.value.split(" ")[0];         console.log("simname:",sim_name);         var sim_list = [{             simulation_name : sim_name,         }];         console.log(sim_list);     }); 

i need array of selected checkboxes in sim_list.. array of values replaced same index ie array[1].. need values 1,2,3,4 in 'var simvalue'

your not pushing data array instead re initiating array

try

var sim_list=[]; var simvalue = $('input[name="simnamecbx"]:checked').each(function() {         var sim_name=this.value.split(" ")[0];         console.log("simname:",sim_name);         sim_list.push({             simulation_name : sim_name,         });      }); console.log(sim_list); 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -