You can dynamically create the options with the following:
selectOpts
[Dd1_data.getPropertyKeys.map(a => `<option value="${Dd1_data[a]}">${a}</option>`).join('')]
output
[selectEl.value]
Dd1_data
Option1 = selected option 1
Option2 = selected option 2
Then on the HTML
<select id="selectEl" onchange="update(out)">[selectOpts]</select>
<p id="out">[output]</p>
A possible problem would be using just the update()
instead of specifying an element to update like update(out)
, in which it would re-display the [selectOpts]
in which it would reset the selection.
Here is also a similar solution to a similar problem.