xxxxxxxxxx
1
<div id="basic1" class="form-outline">
2
<input type="text" id="form11" class="form-control" />
3
<label class="form-label" for="form11">Example label</label>
4
</div>
5
6
<div id="basic2" class="form-outline">
7
<input type="text" id="form12" class="form-control" />
8
<label class="form-label" for="form2">Example label</label>
9
</div>
1
1
xxxxxxxxxx
1
// First autocomplete
2
const basicAutocomplete1 = document.querySelector('#basic1');
3
const data1 = ['One', 'Two', 'Three'];
4
5
const dataFilter1 = (value) => {
6
return data1.filter((item) => {
7
return item.toLowerCase().startsWith(value.toLowerCase());
8
});
9
};
10
11
new mdb.Autocomplete(basicAutocomplete1, {
12
filter: dataFilter1
13
});
14
15
// Second autocomplete
16
const basicAutocomplete2 = document.querySelector('#basic2');
17
const data2 = ['Four', 'Five', 'Six'];
18
19
const dataFilter2 = (value) => {
20
return data2.filter((item) => {
21
return item.toLowerCase().startsWith(value.toLowerCase());
22
});
23
};
24
25
new mdb.Autocomplete(basicAutocomplete2, {
26
filter: dataFilter2
27
});
Console errors: 0