Skip to main content
Known Participant
August 9, 2019
Answered

Multicheck Box Cycle

  • August 9, 2019
  • 1 reply
  • 967 views

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!!!!

This topic has been closed for replies.
Correct answer George_Johnson

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(" ");

}


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;

     }

})();

1 reply

Bernd Alheit
Community Expert
Community Expert
August 9, 2019

To compare values you must use == not only =

Known Participant
August 9, 2019

thank you, it still doesn't work, though

try67
Community Expert
Community Expert
August 9, 2019

Is this an Acrobat form?