I am currently developing an option form where each selection will appear in a different color as the user scrolls down. Once a selection is made, it should be saved and displayed with the chosen color.
https://i.sstatic.net/gvdpt.png
My goal is to save the form, return to the page later, and see my previously selected options along with their associated colors (similar to what is shown in 2021). How can I ensure that the selected option box retains the color of the choice from the drop-down list? What steps should I take to ensure that the selection persists when revisiting the page?
HTML
<form action="" method="post">
{% csrf_token %}
{% for year in years %}
<select name="rating" id="{{year.id}}">
<script src="{% static 'SCS/scripts/script.js' %}"/></script>
<option>Choose From List</option>
<option class=green value="green">High</option>
<option class=yellow value="yellow">Medium</option>
<option class=orange value="orange">Low</option>
<option class=gray value="gray">N/A</option>
</select>
<input type="hidden" name="year" value={{year.fy_year}}>
{% endfor %}
<input id=save_cap type="submit" value="Save">
</form>
CSS
.green{
background-color: green;
}
.yellow{
background-color: yellow;
}
.orange{
background-color: orangered;
}
.gray{
background-color: gray;
}