xxxxxxxxxx
1
<div>
2
<select class="mdb-select md-form select-ordsrc-style" searchable="Search here..">
3
<option value="" disabled="disabled" selected="selected">Choose a Style</option>
4
<option value="6430">CHARISMA</option>
5
<option value="FO901">CHATEAU</option>
6
<option value="6678">CHILTON</option>
7
<option value="2368">CHROMATIC TOUCH</option>
8
</select>
9
<label class="mdb-main-label">Style</label>
10
</div>
11
<div>
12
<select class="mdb-select md-form select-ordsrc-color" searchable="Search here..">
13
<option value="" disabled="disabled" selected="selected">Choose a Color</option>
14
</select>
15
<label class="mdb-main-label">Color</label>
16
</div>
1
1
xxxxxxxxxx
1
$(document).ready(function() {
2
$('.mdb-select').materialSelect();
3
4
$("body").on("change", "select.select-ordsrc-style", function () {
5
6
var selcolor = $("select.select-ordsrc-color");
7
8
$(selcolor).materialSelect({
9
destroy: true
10
});
11
12
$(selcolor).val("");
13
$(selcolor).find("option:not(:first)").remove();
14
15
var url = 'https://api.publicapis.org/entries';
16
17
$.getJSON(url, function(data) {
18
var selcolor = $("select.select-ordsrc-color");
19
20
$.each(data.entries, function(index, value) {
21
$(selcolor).append('<option value="' + value.API + '">' + value.Description +'</option>');
22
23
});
24
25
$(selcolor).materialSelect();
26
27
})
28
.fail(function() {
29
var selcolor = $("select.select-ordsrc-color");
30
$(selcolor).materialSelect();
31
alert("Something went wrong with your request. Please try again later.");
32
});
33
34
});
35
});
36
Console errors: 0