Multicheck Box Cycle

Aug 08, 2019

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

Adobe Community Professional
Correct answer by George_Johnson | Adobe Community Professional

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;

     }

})();

TOPICS
Acrobat SDK and JavaScript, Windows

Views

273

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Multicheck Box Cycle

Aug 08, 2019

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

Adobe Community Professional
Correct answer by George_Johnson | Adobe Community Professional

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;

     }

})();

TOPICS
Acrobat SDK and JavaScript, Windows

Views

274

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 08, 2019 0
Adobe Community Professional ,
Aug 09, 2019

Copy link to clipboard

Copied

To compare values you must use == not only =

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 09, 2019 1
Aug 09, 2019

Copy link to clipboard

Copied

thank you, it still doesn't work, though

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 09, 2019 0
Most Valuable Participant ,
Aug 09, 2019

Copy link to clipboard

Copied

Is this an Acrobat form?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 09, 2019 1
Aug 09, 2019

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

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 09, 2019 0
Adobe Community Professional ,
Aug 09, 2019

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;

     }

})();

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 09, 2019 2
Aug 09, 2019

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 09, 2019 0
Aug 09, 2019

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!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 09, 2019 0