html - jQuery Checkboxes to Populate Mutlidimensional Array -


i have list of checkboxes:

<input type="checkbox" name="a" value="cb1" value2="value01" class="sort" /> <input type="checkbox" name="a" value="cb2" value2="value02" class="sort" /> <input type="checkbox" name="a" value="cb3" value2="value03" class="sort" /> <input type="checkbox" name="a" value="cb4" value2="value04" class="sort" /> 

and do, when toggle these on or off, populate multidimensional array (arr_sort[0][1]), 2 levels only.

here's script code works fine populate single dimensional array, don't know how modify populate multidimensional array.

$(document).ready(function(){      $(".sort").change(function()     {         var arr_sort = new array();          $(".sort").each(function()         {             if( $(this).is(':checked') )             {                 arr_sort.push($(this).val());             }         });         alert( arr_sort );     }); }); 

try replacing arr_sort.push( $( ).val() );

with

arr_sort.push( new array( $( ).val(), $( ).attr( 'value2' ) ) ); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -