I want to get the key of JSON file I have, then get the value in another select input with JavaScript.
This is the JSON file I have:
"city": {
"Afghanistan": [
"Herat",
"Kabul",
"Kandahar",
"Molah",
"Rana",
"Shar",
"Sharif",
"Wazir Akbar Khan"
],
"Albania": [
"Elbasan",
"Petran",
"Pogradec",
"Shkoder",
"Tirana",
"Ura Vajgurore"
],
So what I want is only the country in select input, and when user selects one, all cities should be loaded into the other input.
Here is the HTML code I have:
<div class="form-group">
<label for="Country">Country</label>
<select class="custom-select" id="Country">
<option selected>Choose...</option>
</select>
</div>
<div class="form-group">
<label for="ville">Ville</label>
<select class="custom-select" id="ville">
</select>
</div>