I have input element as range for years. I can change value of year by buttons. I would like to create nested list in second select that depends on year from range input and on first select - id countrySelect.
<input type="range" id="yearRange" min="0" max="3" list="yearsDatalist" value="3"
onChange="changeYear(value)" onInput="changeYearLite(value)">
<datalist id="yearsDatalist">
<option value="0" label="1918"></option>
<option value="1" label="1936"></option>
<option value="2" label="1950"></option>
<option value="3" label="1981"></option>
</datalist>
Then I have two select elements. The first one is static - not necessary to change the values there:
<select id="countrySelect">
<option value="0">Sweden</option>
<option value="1">Germany</option>
<option value="2">USA</option>
</select>
Second select is dependent on year and on values in first select with id=countrySelect
<select id="itemSelection"></select>
I used object for values like this in some different project:
const yearsFilterDataList = {
"1918": {
"0": "Choose model",
"volvo": "Volvo",
"mercedes": "Mercedes",
"saab": "Saab"
}, ...