I created a from where I need to take state and city or District from the user and I have Json file of all the information. I successfully able to fetch the Sates from that JSON file
<label for="state">State</label>
<select name="state" id="state">
<option value="" selected="true" disabled="true">Select your State</option>
</select>
<label for="District">District</label>
<select name="District" id="district">
<option value="" selected="true" disabled="true">Select your district</option>
</select>
<script>
$(document).ready(function(){
var obj = "places.json";
let data;
$.getJSON(obj, function (info) {
data=info;
$.each(data, function (index, value) {
$('#state').append('<option value="' + index + '">' + value.state +
'</option>');
});
});
});
</script>
JSON File content
{
"state":"Delhi (NCT)",
"districts":[
"Central Delhi",
"East Delhi",
]
},
{
"state":"Goa",
"districts":[
"North Goa",
"South Goa"
]
},
What I want when user Select particular state from the dropdown box. then in the district all the districts of that particular state will display there is this possible to do
I try the same way to fetch the districts from the JSON but in drop down i am getting all districts of every state in object. What I want when user Select particular state from the dropdown box. then in the district dropdown all the districts of that particular state will display. Is this possible to do. Suppose I select Goa all districts of goa show in dropdown