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

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -