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

Button 'toggle' between colours and field visible or hidden?

Engaged ,
Apr 08, 2021 Apr 08, 2021

Hi all,

 

Am wondering if it is possible to get a 'toggle' button (that alternates between border colour RED and TRANSPARENT) to also execute some script that will make 3 fields visible or hidden as shown below? e.g. if button pressed and border colour is RED, then the scenario "PRESS BUTTON (if border colour is RED)" shown below should be the case, and if border colour is TRANSPARENT, then the "PRESS BUTTON (if border colour is TRANSPARENT)" case should then be true.

 

The code below is what I have that alternates between the RED and TRANSPARENT border colours for the 'toggle' button (when pressed);

 

event.target.strokeColor = color.equal(event.target.strokeColor, color.transparent) ? color.red : color.transparent;

 

And this is the code I would like to alternate (if even possible!?) between button 'toggle' presses as outlined in my first paragraph;

 

PRESS BUTTON (if 'Fill Colour' is RED)

 

this.getField("Voidtext1").display = display.visible
this.getField("Swapupper1").display = display.hidden
this.getField("Weightupper1").display = display.hidden
}

 

PRESS BUTTON (if 'Fill Colour' is TRANSPARENT)

 

else{

this.getField("Voidtext1").display = display.hidden
this.getField("Swapupper1").display = display.visible
this.getField("Weightupper1").display = display.visible
}

 

TOPICS
PDF forms
608
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Apr 08, 2021 Apr 08, 2021

Try this:

if(color.equal(event.target.strokeColor, color.transparent)){
event.target.strokeColor = color.red;
this.getField("Voidtext1").display = display.hidden;
this.getField("Swapupper1").display = display.visible;
this.getField("Weightupper1").display = display.visible;}
else if(color.equal(event.target.strokeColor, color.red)){
event.target.strokeColor = color.transparent;
this.getField("Voidtext1").display = display.visible;
this.getField("Swapupper1").display = display.hidden;
this.getField("Weightupper1").display = display.hidden;}

View solution in original post

Translate
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 ,
Apr 08, 2021 Apr 08, 2021

Try this:

if(color.equal(event.target.strokeColor, color.transparent)){
event.target.strokeColor = color.red;
this.getField("Voidtext1").display = display.hidden;
this.getField("Swapupper1").display = display.visible;
this.getField("Weightupper1").display = display.visible;}
else if(color.equal(event.target.strokeColor, color.red)){
event.target.strokeColor = color.transparent;
this.getField("Voidtext1").display = display.visible;
this.getField("Swapupper1").display = display.hidden;
this.getField("Weightupper1").display = display.hidden;}

Translate
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
Engaged ,
Apr 08, 2021 Apr 08, 2021
LATEST

Ni Nesa,

 

That's absolutely perfect! many thanks for the response, as always - bang on the money! 😉

Translate
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