Custom HTML prompt: checkbox some checked by default, others not

Can anyone help me understand why one checkbox ("noodle") is checked, but the other ("beef") is not? I expect both to be unchecked by default.

They behave correctly when I use BBEdit to preview it, but when I paste the code to the Custom HTML prompt in KM, the "noodle" checkbox is checked by default.

The code has been simplified. I have more lists. the checkbox under in the "Noodle" block are all checked by default (I don't know why!). All others are not.


    <body data-kmwindow="300, 200" style="background-color:D8D8D8">
    <p> Meat: </p>
            <div><input type="checkbox" name="meat" value="beef"/> beef</div>
    <p> Noodle: </p>
            <div><input type="checkbox" name="noodle" value="noodle"/> noodle</div>

Just discovered, if I change the name="noodle" to name="somethingelse", the checkbox will be unchecked by default. why?

<div><input type="checkbox" name="noodle" value="noodle"/> noodle</div>


Hello @JMichaelTX,

I don't see an answer there. Am I missing anything?

See Custom HTML Prompt action.

Specifically the section where it says “Keyboard Maestro ensures sync between Keyboard Maestro Variables and the HTML form field values”

Basically, you have a Keyboard Maestro variable named "noodle" which is set to 1, and Keyboard Maestro is reflecting this in your form.

Adding the data-kmignore or other attributes would affect this behaviour.

Thanks, @peternlewis. That's very helpful! I see what was going on now.
In addition to the reason you mentioned, it was also because I tried the "window.KeyboardMaestro.Submit()" function. When I click the submit button, with the checkbox item "noodle" selected, KM creates a variable called "noodle" and set it to "1". I did not select "beef", therefore, KM creates a variable called "meat" and set it to "0".

I don't want to create these "HTML name attribute" variables such as "meat" or "noodle", so I guess the best option is not to use the "window.KeyboardMaestro.Submit()" function.

Even without the window.KeyboardMaestro.Submit() the values will still be drawn from the Keyboard Maestro variables of matching names unless you use the data-kmignore or other attributes.

Thanks! That’s helpful to know. I don’t have these variables, so its not a problem for me now. But in case i may create them in future, i guess its better to add data-kmignore to it.