Expand my Community achievements bar.

Script help

Avatar

Level 7

I have a field where users enter the number of people will attend to a conference.

Also I have 3 invisible Fields(A, B, C)

Here is the condition for the script:

If 1-5 people then FieldA visible

If 6-15 people then FieldB visible

If more than 15 people then FieldC visible

Thanks

2 Replies

Avatar

Level 6

if

(this.rawValue<"6")

{fieldA.presence="visible";}

else

{fieldA.presence="hidden";}

A quick thought:

if

(this.rawValue>"5" < "16")

{fieldB.presence="visible";}

else

{fieldB.presence="hidden";}

if

(this.rawValue>"15")

{fieldC.presence="visible";}

else

{fieldC.presence="hidden";}

Avatar

Level 10

Hi,

Close, but when you have multiple conditions in an if statement they need to reference the object's value separately. I would put this in the exit event of the numeric field:

// Hide all fields

FieldA.presence = "hidden";

FieldB.presence = "hidden";

FieldC.presence = "hidden";

// if/else statement

if (this.rawValue < 6) {

     FieldA.presence = "visible";

}

else if (this.rawValue > 5 && this.rawValue < 16) {

     FieldB.presence = "visible";

}

else if (this.rawValue > 15) {

     FieldC.presence = "visible";

}

The last one could just be an else statement, without the test.

Good luck,

Niall