Skip to main content
mmcq
Participant
July 20, 2017
Answered

Newbie- Is it possible to create a button that changes colour as the user clicks it?

  • July 20, 2017
  • 1 reply
  • 542 views

Hello,

I'm very new to creating PDF's and Javascript, I was hoping to get some advise.

I want to create a button that will cycle through various colours when it is clicked, potentially 4 colours. I'm using Acrobat Pro XI and the end user will be using Reader XI.

Is this possible? Forgive me if this has been asked before, I looked through the forums and did some google searching but I couldn't find what I needed.

Many thanks for any support!

This topic has been closed for replies.
Correct answer try67

This code will create a "traffic-light" effect. You can adjust it to use more or less colors, of course.

if (color.equal(event.target.fillColor, color.red)) event.target.fillColor = color.yellow;

else if (color.equal(event.target.fillColor, color.yellow)) event.target.fillColor = color.green;

else event.target.fillColor = color.red;

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
July 20, 2017

This code will create a "traffic-light" effect. You can adjust it to use more or less colors, of course.

if (color.equal(event.target.fillColor, color.red)) event.target.fillColor = color.yellow;

else if (color.equal(event.target.fillColor, color.yellow)) event.target.fillColor = color.green;

else event.target.fillColor = color.red;

mmcq
mmcqAuthor
Participant
July 24, 2017

This is brilliant, thank you so much, this is exactly what I was looking for, I have been looking for ages and you got back so quickly.

Thank you!