I’m processing checkboxes and setting a variable through javascript in custom HTM prompt.
I’m trying to set KM to ignore checkboxes instead of automatically setting the variable. by adding the attribute data-ignore=1
However, the variable favorites keeps being set to 0 or 1.
I can catch my javascript result if I use different variable name instead of favorites, so the script seems to work.
I’d really appreciate if someone Can help me to fix this custom HTM prompt so KM doesn’t set the variable favorites automatically. I’m pasting my HTM entry below.
Sorry for the format. I’m not sure how to make HTM codes to show up. I just put space after and before < and >.
Thanks!
< script >
function submitIt() {
favorites = window.document.forms[‘theForm’].elements[‘favorites’]
str = “[“
for (f in favorites) {
if (favorites[f].checked) {
str+=””"+favorites[f].value+"","
}
}
str=str.substring(0,str.length-2)+"]"
window.KeyboardMaestro.SetVariable(‘favorites’, str)
window.KeyboardMaestro.Submit(‘OK’)
}
< /script >
< form name=‘theForm’ >
< input type=“checkbox” name=“favorites” data-ignore=1 value=“Apple” >Apple
< input type=“checkbox” name=“favorites” data-ignore=1 value=“Orange” >Orange
< input type=“checkbox” name=“favorites” data-ignore=1 value=“Other” >Other
< button name=“OK” type=“submit” onclick=“submitIt()” >OK< /button >
< /form >