I am trying to handle a traditional key-value using datalists:
Verify and report that only existing values are allowed.
Store the key in a way that is easy to fetch.
Submit the key to the database.
What I found is that datalists NOT are built for traditional “key-values pair”.
I also found that there are many ways to work around this limitation by looping list, find the key and create hidden field etc.
I have got a solution from @PaulOB that works perfect for #1. But I am still struggling how to fetch values and submit the keys to the database. In order to make it easier to fetch I assume that the keys are easier to fetch when stored in at the input level.
Storing the keys in input makes it simpler to verify as I only have to loop through the input elements (not all options)