jquery - Create mutidimentional Associative array in javascript -
i need create multidimensional array in javascript
my code follows console error "uncaught typeerror: cannot set property 'time' of undefined"
var timelogdetails = {}; $('.time_input').each(function(i, obj) { timelogdetails[i]['time'] = $( ).val(); timelogdetails[i]['timelog'] = $( ).attr('timelog'); });
you need first create array timelogdetails
, , push in data it.
for example:
var timelogdetails = [ ]; $('.time_input').each(function(i, obj) { timelogdetails.push( { 'time': $(this).val(), 'timelog': $(this).attr('timelog') } ); });
now, may access information using:
timelogdetails[0]['time']
or timelogdetails[0].time
Comments
Post a Comment