Help with Custom HTML Prompt


I need help with HTML prompt that would ask for a menu of choices that is screen size wide and long, contain two choice in each one of the four columns.

Here is what I came up with so far, but it does not seem to work well:

<!DOCTYPE html>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Order Palette</title>

<style type="text/css">
	body {
		font-family:Verdana, Arial, Helvetica, Geneva, Tahoma, sans-serif;
		margin: 5px;
		background-color: #838383;	

	table, th, td {
		/*border-collapse: collapse;*/
		border: 1px solid #000000;
		background-color: #838383;
		padding: 5px;
		vertical-align: text-top;
		vertical-align: top;
		width: 100%;

<meta name="viewport" content="width=device-width, initial-scale=1">
* {
  box-sizing: border-box;

/* Create four equal columns that floats next to each other */
.column {
  float: left;
  width: 25%;
  /* padding: 10px; */
  /* height: 300px; /* Should be removed. Only for demonstration */

/* Clear floats after the columns */
.row:after {
  content: "";
  display: table;
  clear: both;

<ul class="checkbox-grid">

<div class="row">
  <div class="column" style="background-color:#aaa;">
    <h2>Column 1</h2>
      <li><input type="checkbox" name="text1" value="value1" /><label for="text1">Text 1</label></li>
      <li><input type="checkbox" name="text2" value="value2" /><label for="text2">Text 2</label></li>
  <div class="column" style="background-color:#bbb;">
    <h2>Column 2</h2>
    <li><input type="checkbox" name="text3" value="value3" /><label for="text3">Text 3</label></li>
    <li><input type="checkbox" name="text4" value="value4" /><label for="text4">Text 4</label></li>
  <div class="column" style="background-color:#ccc;">
    <h2>Column 3</h2>
    <li><input type="checkbox" name="text5" value="value5" /><label for="text5">Text 5</label></li>
    <li><input type="checkbox" name="text6" value="value6" /><label for="text6">Text 6</label></li>
  <div class="column" style="background-color:#ddd;">
    <h2>Column 4</h2>
    <li><input type="checkbox" name="text7" value="value7" /><label for="text7">Text 7</label></li>
    <li><input type="checkbox" name="text8" value="value8" /><label for="text8">Text 8</label></li>

Your opening <html> tag comes too late, you've got two opening <head> tags, the first style block lacks a closing tag, you don't close the body or html sections (although there may be some code missing), putting an h2 directly inside a ul element is invalid markup, and there's no sign of a form.

While web engines will do their best to render a page, and so will cope with the mistakes, it'll take you into "undefined behaviour" territory -- so start by fixing those.

In what ways does it not "work well"? A mocked-up image of what you'd like to have happen would be useful here.

@Nige_S, appreciate your comments. I can certainly make several changes you are suggesting, but I doubt that I can write the html script that will actually work. I've been learning bits and pieces of html coding, but clearly not enough to be successful.

I was inspired to ask for help by this post by @RogerW and @mrpasini help to fix his html code. I was hoping someone can help me to fix my html code, so I can built on it to create the following html menu:

Since there are 4 columns and multiple items, I was hoping to just start with 2 items per column to make it easy.

I am planning to use variables from the html code menu (checkmarks by each item) to be used in KBM script - this part I probably can accomplish myself.

Alternatively I am would happy to continue learning and make one change at the time, if it is easier path.

Roger did me the courtesy of sharing his macro and being explicit about what he wanted. It would help your cause to share those four columns of options and explain how the columns should be limited to two choices when they clearly have multiple sections.

So don't worry about code, explain how you want the menu to function. But share the text so it doesn't have to be keyboarded.

@mrpasini I currently have multiple KBM macros which are triggered by mouse clicking on each one of the items on the palette on the screenshot. I can only choose one item at the time with the current set-up. Once clicked, macro chooses the corresponding items in the Electronic Medical Record (EMR) order list - a long list of options by scrolling down the list x times (this variable is different for each item clicked). It's little oversimplified, but hopefully it makes sense. EMR is reached via citrix and thus I have very limited options to create macros with KBM. Making one choice at the time and waiting for each macro to complete prior to choosing another one is cumbersome and takes too much time.

I am hopeful to create an html menu with checkboxes instead of this palette . I'd click on as many or as few of check boxes as needed, then click "order" or "enter" button and the bottom of the menu and let all the macros run sequentially one at the time after that. I am thinking I'd assign a variable to each checkbox, then check whether each one of these have "0" or "1" value, and execute macros for the checkboxes with value "1".

Hope it makes sense. I am hopeful that if you can show me how to make an html menu with just 4 columns with a couple of checkboxes in each, I can take it from there and populate the rest.

Here are a few macros as example, but I think these would just muddy the water.

. Main labs ordering.kmmacros (19.5 KB)
#Orders (Labs, etc) Macros.kmmacros (328.9 KB)

Make a Custom HTML Prompt Macro List Macro (v9.2)

Roger Wells
Lexingtin, KY

Thanks @RogerW, I did not see this one before - I'll take a look at it.

Here's a demonstration macro that shows you how to layout four columns with groups of checkboxes, all independent of each other.


It displays a report of the results using Keyboard Maestro variables so you can link the checkmark to whatever process you want to enable.

Choices Macro (v10.2)

Choices.kmmacros (6.0 KB)

Keyboard Maestro Export

1 Like

I'm in a similar position, only a couple of pages ahead of you!

That's helpful -- and instantly provokes a question. The layout, particularly the widowed "heading" at the bottom of column 1, implies a "desktop publishing" type of text flow through your columns, where adding something to the middle of column 1 will push the last item to the top of 2 (which pushes the last of 2 to the top of 3, etc). Is that requirement, or just how it turned out? Is, perhaps, the list being generated on the fly? It'll be a lot easier if it isn't, and you can hard-code it (with sensible breaks!).

Edit to add:
So, as I'm trying to learn this stuff, here's a stab at a Prompt that borrows from @mrpasini's. I've used fieldsets rather than headings to group sections together, forced the window to full-screen, and jammed the buttons down to the bottom-right. labels work properly, allowing your users to click the box or the label to select an item.

I used local variables, but had to change my normal Local_variableName to localVariableName because of the "space to underline" (and vice versa) conversion when moving between KM and the web form -- mentioning it because that caught me out for a while :wink:

I've tried to include things you've shown in your image, like an horizontal divider within a section, so hopefully you'll be able to build out from it, style it to your own liking, etc.

I won't claim the coding is particularly good, but it helped me learn some stuff and might give you some ideas.

Custom HTML Prompt Test.kmmacros (10.0 KB)


1 Like

Applauding 1) the use of local variables and 2) including the id in the checkbox so the label is clickable. :+1: :+1:

@mrpasini and @Nige_S,

Thank you so much for taking time to not only help but to teach me how it can be done.

This is fantastic!

1 Like

If you can learn by podcast, have listen to the "Programming By Stealth" series -- you'll find the introduction here and can subscribe via the usual services. It starts with the basics of HTML, moves through CSS and basic JavaScript, and so on. Good show notes, and after the first few shows there are "assignments" at the end of each that are then discussed in the next.

This sounds great! I will give it a try!

You are absolutely correct @Nige_S - the list was generated on the fly and I hated how a new item would push the whole layout around, requiring correction etc.

Your solution using fieldsets (first time I hear about these) is fantastic, and perfect for my application.

I am also very happy with clickable labels and dividers. This is really above an beyond what I've expected. Very thankful for your and @mrpasini 's help.

1 Like

@mrpasini I've been trying to figure out how to include a code into this HTML that would allow me to press return key and it will be interpreted as a click the OK button. I've found multiple different solutions on the web and can see how it works, but am unable to apply it to my particular HTML, designed by you.

Would you have a moment to help, please?

Put this in the head section of the HTML:

function KMInit(){window.addEventListener("keydown",function(e){e.preventDefault();if(e.code=='Enter'){window.KeyboardMaestro.Submit('OK');}});}

and in the body, put this (or something similar:

<button name="OK" class="button" type="submit" onclick="window.KeyboardMaestro.Submit('OK')">OK</button>

@mrpasini - really appreciate your quick response. It works great! Thank you.

1 Like