javascript - Create Associative array with unique keys -


i'm creating associative array (technically object) this, , keys should strings.

var j = <?php echo $max_key ?>; var id = "ele"+j; eledetailstop[id] = {id: id, size : "100%", sizelabel : 12}; 

finally object stored in db json string.

my problem generating value j. keys ele0, ele1, ele2...etc. so, value of j should +1 max value of stored keys in db. let's max value ele4, next value of j should 5. so, can generate new id ele5

how done ?

var max = <?php echo $max_key ?>; var eledetailstop = []; (var id = 0; id < max; id++) {   eledetailstop["ele" + id] = {id: id, size : "100%", sizelabel : 12}; } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -