Button actions using JavaScript

New Here ,
Apr 30, 2020 Apr 30, 2020

Copy link to clipboard

Copied

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, How to

Views

74

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
community guidelines
New Here ,
Apr 30, 2020 Apr 30, 2020

Copy link to clipboard

Copied

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.

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
community guidelines
Adobe Community Professional ,
Apr 30, 2020 Apr 30, 2020

Copy link to clipboard

Copied

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

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