I'm attempting to alert the keys (NOT values) of an object specified by a user selected value but I'm having no luck. I can successfully alert the keys if I manually input the object name in the for loop. Heres the snippet of my code:
<select id="state" class="pure-input-1-2" onchange="populateAirport(this.value)">
<option value = ""></option>
<option value = "AL">AL</option>
<option value = "AK">AK</option>
</select>
function populateAirport(selectedValue){
AL = {"Birmingham–Shuttlesworth International Airport":"BHM","Huntsville International Airport":"HSV"}
AK = {"Ted Stevens Anchorage International Airport":"ANC","Fairbanks International Airport":"FAI","Juneau International Airport":"JNU","Ketchikan International Airport":"KTN"}
for(var i in selectedValue){//if I replaced 'selectedValue' with 'AL' I alert the keys in the object just fine
alert(i);
}
}
I just want to be a to dynamically reference an object based on the selected value. Thanks in advance for your help.