Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Color Changing Form Button with Javascript  (Read 4805 times)

mrosario

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 1
Color Changing Form Button with Javascript
« on: May 18, 2019, 08:08:35 PM »

Hi, I have recently received assistance with some scripting on another website but still seem to be having issues and I have come to the conclusion it is because I am in a non-adobe application. I have a few things I am trying to do:
(1) I am trying to create a button that goes from one color to transparent each time it is pressed. I have gotten it to work with the following code: "event.target.fillColor = (color.equal(color.red, event.target.fillColor)) ? color.transparent : color.red;". But for some reason I can't get it to work on yellow. When I put "yellow" in the code, one press will turn the button yellow but will no longer click to transparent and back again. I have gotten it to work on three colors, green, red and black.
(2) In regards to the colors I am needing to make the individual buttons, can I adjust the colors to a specific one? For instance, when I have green set as the color - it turns a lime green but would like to adjust it to a forest green. Is that possible with color codes??
(3) Finally, I am needing to link the buttons. For instance, on page 3 of the document I have button that is clicked and turned to red. I need another button to mimic this action on page 20. In regards to this I also have a code that works for Adobe applications: "var newColor = (color.equal(color.red, event.target.fillColor)) ? color.blue : color.red; 
event.target.fillColor = newColor; 
this.getField("Name of other field").fillColor = newColor;"
This works but only for the 2nd button. Meaning, when I click the button on page 3, that button doesn't change colors but it does change the colors on page 20.

Any assistance is greatly appreciated!!
Logged

chagen

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 1
Re: Color Changing Form Button with Javascript
« Reply #1 on: September 04, 2020, 10:38:40 PM »

(1) Transparent won't work on text
(2) For changing the color to forest green:  ["RGB",0.133,0.545,0.133]
(3) You'll need it to loop thru the form (all pages) to find all the buttons
Logged