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

php - Wordpress: Link a post to posts of another category manually -

delphi xe7 upload/download dropbox file using the rest client and show progress -

java - Get more than One value and display it -