Shared action freezes using 'execute JavaScript'
I have an advanced action I want to use on multiple with javascript and toggle a variable. The script works fine if I use it in an advanced action. The script shows and hides images in a string based on what is clicked for a visual aid I am working on. I won't pretend to be any good at JavaScript since I have no formal education in writing code of any form. Perhaps that plays a part in this issue.
I can save the advanced action as a shared action. When I try to add the shared action to a button and open the properties window, the shared action window does not allow me to change the variable, Captivate locks up and doesn't allow me to closes the shared action window.
If I make multiple buttons with individual advanced actions, it works with no problems.

var mods = window.cpAPIInterface.getVariableValue("modulesQty")+1; //number of objects + 1
var firstmod = 0;
var secondmod = 0;
var firstfull = 0; //first module broken was found == 1
function ResetIssue() { //hides all modules with a 0, not broken
for (var h = 1; h < mods; h++) {
var stat = window.cpAPIInterface.getVariableValue("vm" + h);
if (stat === 0) {
cp.hide("m" + h);
}
}
}
ResetIssue();
function multiIssue() { //hides all modules between 2 broken modules
for (var h = 1; h < mods; h++) {
var stat = window.cpAPIInterface.getVariableValue("vm" + h);
if (stat === 1) {
if (firstfull === 0) { //finds the first bad module
firstmod = h;
firstfull = 1;
}
if (firstfull === 1) { //finds the last module that is broken
secondmod = h;
}
}
}
}
multiIssue();
if (firstmod != 0) {
for (var i = firstmod; i < secondmod + 1; i++) { //will hide any objecs with a variable of 1
cp.show("m" + i); //shows all modules between firstmod and secondmod
}
}
