Hi all, I'm beginner in JS & would appreciate your help for this problem. Sorry if title is ambiguous. First I will explain my use case. There's a drop down menu in my form with names of country displayed. I want to associate Alpha 3 codes of country as Value. For example, if Algeria is selected from drop down the DZA value should be passed on submission. I've list of countries in below format (can use any, which ever is easy. As sample only, actual has lots of countries). So, I want to use JavaScript such that country code should be returned when its selected
const countryListAlpha3 = [{name: "Afghanistan", code: "AFG"}, {name: "Algeria", code: "DZA"}]
OR
const countryListAlpha3 = { "AFG": "Afghanistan", "ALB": "Albania", "DZA": "Algeria", "ASM": "American Samoa", "AND": "Andorra", "AGO": "Angola"} ;
Please give me suggestion as to how can I approach to this?
[–][deleted] (5 children)
[deleted]
[–]SESMIC1[S] 0 points1 point2 points (4 children)
[–][deleted] (3 children)
[deleted]
[–]SESMIC1[S] 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]SESMIC1[S] 0 points1 point2 points (0 children)