I'm able to populate the names of option fields for the #maplist select dropdown:
$.each(mapsArray, function(x,y) {
$.each(y, function(j,z) {
$('#maplist').append(
$('<option></option>').html(z.mapName)
);
});
});
But I can't figure out how to add .val to each option field (in this case, it would be z.mapID.$id)
$.each(mapsArray, function(x,y) {
$.each(y, function(j,z) {
$('#maplist').append(
$('<option value="'+ z.mapName +'">'+ z.mapName +'</option>');
);
});
});
I would do it this way rather than concatenating a bunch of strings.
$.each(mapsArray, function(x,y) {
$.each(y, function(j,z) {
$('#maplist').append(
$('<option></option>').val(z.mapName).text(z.mapName);
);
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With