-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathajax_dropdown.js
More file actions
47 lines (44 loc) · 1.16 KB
/
Copy pathajax_dropdown.js
File metadata and controls
47 lines (44 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
$('#country').change(function(){
var countryID = $(this).val();
if(countryID){
$.ajax({
type:"GET",
url:"{{url('api/get-state-list')}}/"+countryID,
success:function(res){
if(res){
$("#state").empty();
$("#state").append('<option>Select</option>');
$.each(res,function(key,value){
$("#state").append('<option value="'+value.id+'">'+value.state_name+'</option>');
});
}else{
$("#state").empty();
}
}
});
}else{
$("#state").empty();
$("#city").empty();
}
});
$('#state').on('change',function(){
var stateID = $(this).val();
if(stateID){
$.ajax({
type:"GET",
url:"{{url('api/get-city-list')}}/"+stateID,
success:function(res){
if(res){
$("#city").empty();
$.each(res,function(key,value){
$("#city").append('<option value="'+value.id+'">'+value.city_name+'</option>');
});
}else{
$("#city").empty();
}
}
});
}else{
$("#city").empty();
}
});