Custom HTML Prompt: How to Supply This Data via a KM Variable?

My macro Mirror Mirror uses the HTML prompt with several dynamic popup menus.

The trick is to wrap the actions in a loop that builds a variable for the popup which the prompt can display using a Javascript call. All of that is illustrated in the macro linked above.