2 Replies Latest reply on Apr 6, 2013 12:20 PM by The King of Milk2

    Trying to do an 'if' function need help

    The King of Milk2

      I have four values that I want to input into a field. What I am trying to make happen is when you type in a letter, that text field will then highlight or fill to a certain color. Can anyone help me? And I want to have four values in it. The values would be "G" "R" "Y" and "0". If I type in "G" I woud like the field to fill/highlight green. I am not good at scripting. any help would be amazing.

        • 1. Re: Trying to do an 'if' function need help
          Mandy_Wiesener

          I'm not sure if I understand you right.

          Here is a script that check if you leave the field which entry the user makes.

          If the entry is a "G" the field will be filled with color.

           

          You have to use this script in the change-event of the script editor. This allows to entry only G or R or Y or 0.

          if(xfa.event.newText.match(/[^GRY0]/))
          {
           xfa.event.change = "";
          }
          

           

          And this script you have to use in the exit-event of the script editor. This checks if your entry is a "G".

          if(this.rawValue == "G")
          {
              Textfeld1.fillColor = "245,245,0";
          }else
          {
              Textfeld1.fillColor = "255,255,255";
          }
          

          Bild 3.jpg

           

          The script editor you will find about "window".

           

          Hope it will helps you,

          Mandy

          • 2. Re: Trying to do an 'if' function need help
            The King of Milk2 Level 1

            It was helpful and got it working. I'm trying to mess with it right now. But with that script it only makes it green. I tied typing in r or y and it comes up white or no fill. But I'm trying to tinker with it. I appreciate it so much Mandy!!!