Copy link to clipboard
Copied
Hi all,
Could anyone please help me to figure out how to fix the below script? Checkbox is returning false, even when checked.
I recommend you keep the checkbox value in a variable that you declare outside the ScriptUI Window scope. Then you make an event listener "onClick" that updates it whenever user clicks the checkbox.
Here's one way to code it:
var myCheckBoxValue = false;
var myWindow = new Window("dialog");
myWindow.orientation = "column";
var test = '';
var button = myWindow.add("button", undefined, "Run");
var checkbox = myWindow.add("checkbox", undefined, "Checkbox");
checkbox.onClick = function () { myC
...
It seems enough:
var myWindow = new Window("dialog");
var button = myWindow.add("button", undefined, "Run");
var checkbox = myWindow.add("checkbox", undefined, "Checkbox");
button.onClick = function() { myWindow.close() };
myWindow.show();
if ( checkbox.value == true ) alert("Checkbox returned true")
else alert("Checkbox returned false")
(^/) The Jedi
Copy link to clipboard
Copied
You need to check checkbox.value
Copy link to clipboard
Copied
I recommend you keep the checkbox value in a variable that you declare outside the ScriptUI Window scope. Then you make an event listener "onClick" that updates it whenever user clicks the checkbox.
Here's one way to code it:
var myCheckBoxValue = false;
var myWindow = new Window("dialog");
myWindow.orientation = "column";
var test = '';
var button = myWindow.add("button", undefined, "Run");
var checkbox = myWindow.add("checkbox", undefined, "Checkbox");
checkbox.onClick = function () { myCheckBoxValue = this.value };
button.onClick = function () { test = '0'; myWindow.close() };
myWindow.show();
if (test != '') main(test);
function main() {
if (myCheckBoxValue == true) {
alert("Checkbox returned true");
} else {
alert("Checkbox returned false");
}
}
- Mark
Copy link to clipboard
Copied
It seems enough:
var myWindow = new Window("dialog");
var button = myWindow.add("button", undefined, "Run");
var checkbox = myWindow.add("checkbox", undefined, "Checkbox");
button.onClick = function() { myWindow.close() };
myWindow.show();
if ( checkbox.value == true ) alert("Checkbox returned true")
else alert("Checkbox returned false")
(^/) The Jedi