• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Multicheck Box Cycle

Community Beginner ,
Aug 08, 2019 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!!!!

TOPICS
Acrobat SDK and JavaScript , Windows

Views

645

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
community guidelines

correct answers 1 Correct answer

LEGEND , Aug 09, 2019 Aug 09, 2019

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;

     }

})();

Votes

Translate

Translate
Community Expert ,
Aug 09, 2019 Aug 09, 2019

Copy link to clipboard

Copied

To compare values you must use == not only =

Votes

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
community guidelines
Community Beginner ,
Aug 09, 2019 Aug 09, 2019

Copy link to clipboard

Copied

thank you, it still doesn't work, though

Votes

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
community guidelines
Community Expert ,
Aug 09, 2019 Aug 09, 2019

Copy link to clipboard

Copied

Is this an Acrobat form?

Votes

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
community guidelines
Community Beginner ,
Aug 09, 2019 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(" ");

}

Votes

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
community guidelines
LEGEND ,
Aug 09, 2019 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;

     }

})();

Votes

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
community guidelines
Community Beginner ,
Aug 09, 2019 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!!!

Votes

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
community guidelines
Community Beginner ,
Aug 09, 2019 Aug 09, 2019

Copy link to clipboard

Copied

LATEST

Never mind!!! I just realized they alll had the same name

thank you sooooooo much to all of you guys!

You are amaizing!

Votes

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
community guidelines