Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2014
    Thanked 0 Times in 0 Posts

    Smile Fill color based on input

    Hello guys,

    I'm not sure if I'm breaking any forum rules as I'm just new here but it's urgent.

    I've started learning javascript today, I've tried to write a code to fill a text field with specific colours based on input in Acrobat PDF.

    What I want is when I write A into the box, field color goes red; if I write B, field color goes green and when C, color goes blue.

    I've tried many many ways, when I write this it just turns every letter I write to B with a green field.

    I'm using Acrobat Professional XI

    (function () {

    var val = event.value;

    if (!event.value){
    event.target.fillColor = color.transparent;

    else if(event.value = "B")
    event.target.fillColor = color.green;

    else if(event.value = "A")
    event.target.fillColor = color.red;

    else if(event.value = "C")
    event.target.fillColor = color.blue;


  2. #2
    Regular Coder
    Join Date
    Apr 2012
    St. Louis, MO
    Thanked 101 Times in 101 Posts
    In your conditionals, there should be two equal signs. Two is for comparison, one is for setting, that's why it's setting every one to B (B is the first in your code.)

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts