Custom HTML

I am using the custom html prompt. Is there a way to make the State to Search at the bottom a drop down list which would show the full state name and abbreviation? So that I could use either one as a variable?

If I understand the question properly, you'd just need to use the HTML <SELECT> tag to build your menu. You could code each state like this:

<option value="CO,Colorado">Colorado</option>

The response from that field could then be split using the arrays feature in Keyboard Maestro. How you exactly build that on your form will depend on how you put your form together :). I asked ChatGPT to generate a list of abbreviation-name pairs, and wrote a quick demo macro:

Download Macro(s): State picker.kmmacros (5.0 KB)

Macro screenshot

Macro notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System information
  • macOS 14.4.1
  • Keyboard Maestro v11.0.2

First, the list is stored to a variable, then a regular expression modifies each line into HTML form. That is then merged with the other form HTML in a variable, and then displayed using a one-line Javascript. Pick a state, and a window will appear showing the abbreviation and full name of the one you selected.


You don't have to do it this way; you could just run this once and add a Display Text in Window to display the localTheHTML variable, then copy and paste that output into your form code—just the bits relevant to the pop-up itself, not the surrounding HTML, of course.

Does that help?

-rob.

Thanks rob

That will work

Roger

Rob

I have used chatgpt but never for this type of coding.

I just tried this and it worked like a charm:

list <option value=4255869|state code|state">State</option

it gave me this for every state.

<option value="4255869|AL|Alabama">Alabama</option>

Thanks for the great response

Roger

1 Like