I’m trying to update some of my old macros to the new and nice HTML prompt.
Now I stumbled upon one of my (old style) user prompts where I could add new items to the dropdown menu through the front-end of the macro by appending new “|”-separated values to an existing variable in the dropdown menu.
Is it understandable what I mean?
The menu was basically built like this:
%Variable%ES__Save to%|-|~/Desktop__Desktop|~/Downloads__Downloads|-|📥 Add new destination|-|%Variable%ES__Added destinations%
Now I’m wondering how/if I can achieve something similar with the HTML prompt?
Thanks for the link, JMichael. I’ve already managed to set up a customizable dropdown with the help of the javascript from there. Just struggling now to make it remember the previously selected value. But I’ll figure out…
When you submit the HTML prompt form, the KM vars are set to what the user has selected. So the next time you run the prompt, it should show that selection if you did not delete or reset the KM var.
Yes, today I’ve already build a HTML prompt where it works this way. But somehow it doesn’t work with the js-built selection list. The value gets submitted to the variable but the corresponding option is not selected in the next run.
iNik reported a similar issue, which he fixed with a delay. But perhaps using the <script>document.write(window.KeyboardMaestro.GetVariable('Initial'))</script>
that Peter suggested will fix it.
It’s in the tmpSaveTo variable, which also forms the name attribute of the select menu (<select name="tmpSaveTo">). It matches the value attribute of one of the option tags (<option value=…>), which are built by the javascript from the tmpSaveToList array.