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

Button actions using JavaScript

New Here ,
Apr 30, 2020 Apr 30, 2020

Hi,

I'm creating an interactive Bingo board so my student can complete activities at home. The parent will click the button to mark done.

 

I found the following code to change the color of a button.

 

If only once then set the fill color as blue and then apply the following JavaScript code as the MouseUp event of the button:

event.target.fillColor = color.green;

 

If you want it to change back and forth, use this code:

event.target.fillColor = (color.equal(color.blue, event.target.fillColor)) ? color.green : color.blue;

 

Is there a way to add to the change back and forth code to add words. I want add the word 'Done'? Blue would be blank. Once the button is clicked, it would change to green and the word done would appear. I actually would prefer yellow but I will just change the word.

 

Also, is there a way to add the same property to all buttons at once or do I need to add the script to each bingo board?

I really would like a transparent circle to cover the square but that is a little too advanced for me right now!

 

Thank you for your help!!!

TOPICS
Acrobat SDK and JavaScript
482
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
New Here ,
Apr 30, 2020 Apr 30, 2020

I just learned how to add 'done' as a label and change the color to black. When the button is clicked and the color of the button turns yellow, the word 'done' appears.

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 30, 2020 Apr 30, 2020
LATEST

The best way to develop something like this is to put the button code into a folder level function and then call the function from each button. For example

function ToggleColor()
{
    event.target.fillColor = (color.equal(color.blue, event.target.fillColor)) ? color.green : color.blue;
}

 

If there are a lot of buttons, then you can use a console script to set them all up. If the fields are named correctly you can do it with a single line of code. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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