Copy link to clipboard
Copied
Hello,
I am trying to make a Checkbox cycle between check, cross, and empty. I found this code, but can't get it to work
this.ui.oneOfChild.mark = this.value.oneOfChild.value === 1? "check":"cross";
I have also seen that people talk about "faking" it with a button, and I tried this:
var i;
if (i=2){
this.getField("Button1").buttonSetCaption("X");
i=0;
}
if (i=1){
this.getField("Button1").buttonSetCaption("/");
i++;
}
if (i=0){
this.getField("Button1").buttonSetCaption(" ");
i++;
}
also doesn't work.
Thank you so much for taking the time to help!!!!
If you place the code in the Mouse Up event of the button that you want to control, it could be something like:
(function () {
// Get this button's current caption
var val = event.target.buttonGetCaption();
// Set caption to the next one in the loop
switch (val) {
case "X" :
event.target.buttonSetCaption("");
break;
case "/" :
event.target.buttonSetCaption("X");
break;
case "" :
event.target.buttonSetCaption("/");
break;
}
})();
Copy link to clipboard
Copied
To compare values you must use == not only =
Copy link to clipboard
Copied
thank you, it still doesn't work, though
Copy link to clipboard
Copied
Is this an Acrobat form?
Copy link to clipboard
Copied
Yes, I am using Acrobat with the Adobe Creative Cloud
currently, I am trying this, but still can't get it to work
var x = getField("Button1");
var xC = x.buttonGetCaption.valueAsString;
if (xC.value == " "){
x.buttonSetCaption("/");
}
if (xC.value == "/"){
x.buttonSetCaption("X");
}
if (xC.value == "X"){
x.buttonSetCaption(" ");
}
Copy link to clipboard
Copied
If you place the code in the Mouse Up event of the button that you want to control, it could be something like:
(function () {
// Get this button's current caption
var val = event.target.buttonGetCaption();
// Set caption to the next one in the loop
switch (val) {
case "X" :
event.target.buttonSetCaption("");
break;
case "/" :
event.target.buttonSetCaption("X");
break;
case "" :
event.target.buttonSetCaption("/");
break;
}
})();
Copy link to clipboard
Copied
that work perfectly!
and I would love for a little bit more of help. As I need to duplicate this button several times, but all of them change at the same time. I have tried making one var1, and the other var2, placed them in the switch, but they all change as one.
Thank you so much for your knowledge and help!!!
Copy link to clipboard
Copied
Never mind!!! I just realized they alll had the same name
thank you sooooooo much to all of you guys!
You are amaizing!