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
Post a Comment