I can fill in the parameter field names for the drop-down list #maplist:
#maplist
$.each(mapsArray, function(x,y) { $.each(y, function(j,z) { $('#maplist').append( $('<option></option>').html(z.mapName) ); }); });
But I can’t understand how to add .valoptions to each field (in this case it will be z.mapID.$id)
.val
z.mapID.$id
I would do it like this rather than concatenating a string of strings.
$.each(mapsArray, function(x,y) { $.each(y, function(j,z) { $('#maplist').append( $('<option></option>').val(z.mapName).text(z.mapName); ); }); });
$.each(mapsArray, function(x,y) { $.each(y, function(j,z) { $('#maplist').append( $('<option value="'+ z.mapName +'">'+ z.mapName +'</option>'); ); }); });
Use .attr ():
http://api.jquery.com/attr/
$.each(mapsArray, function(x,y) { $.each(y, function(j,z) { $('#maplist').append( $('<option></option>').html(z.mapName).attr('value', z.mapID.$id); ); }); });