'How to populate select field based on previous inputs?

I am trying to create a multiple choice style quiz. Currently I have a form that looks like this:

enter image description here

The options field uses JavaScript to add/remove new options and the user can fill them out. Those inputs get put into an ordered list.

Essentially, I want the user to be able to choose values in the “correct answer” select field based on the ordered list inputs above.

For example, in this case, I would want the correct_answer to have 3 select fields: “example”, “for”, “options”

What is the best way to achieve this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source