Expand my Community achievements bar.

SOLVED

Trying to do an 'if' function need help

Avatar

Level 2

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 Accepted Solution

Avatar

Correct answer by
Level 5

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

View solution in original post

2 Replies

Avatar

Correct answer by
Level 5

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

Avatar

Level 2

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!!!