Skip to main content
stevenc65695984
Participant
January 24, 2017
Question

show and hide fields based on another field value equal to or greater than

  • January 24, 2017
  • 22 replies
  • 6593 views

Good evening,

I want to show and hide a field based on another field's numerical value being equal to or greater than. The scenario is, if one field name "text1" (which has a calculation formula of its own) is equal to or greater than 50k, I want the form to show 7 other fields. If its less than 50k then I want those fields to be hidden. Therefore, those fields should be always hidden unless the value goes 50k+ in "text1". I have been looking around for a while been the syntax I keep getting doesnt seem quite right.

Thanks in advance!

This topic has been closed for replies.

22 replies

try67
Community Expert
Community Expert
January 24, 2017

At the end of your calculation script for "text1" add this code:

if (event.value>=50000) {

    this.getField("field1").display = display.visible;

    this.getField("field2").display = display.visible; // etc.

} else {

    this.getField("field1").display = display.hidden;

    this.getField("field2").display = display.hidden; // etc.

}

Edit: Added the "equals to" operator...

stevenc65695984
Participant
January 24, 2017

Thanks for this!

I inputed your code after the calculation code and doesnt seem to work correctly. When I place a value that is above 50000 it doesnt hide the field. This is how I have it:

var total = this.getField("Fee rate").value * this.getField("Quantity").value + this.getField("Cap for related expenses ie cost of meals travel other incidentals etc").value;

this.getField("Total SOW value").value = total;

if (event.value>=50000) { 

    this.getField("Text2").display = display.visible;

} else { 

    this.getField("Text2").display = display.hidden; 

}

Thanks in advance.

try67
Community Expert
Community Expert
January 24, 2017

You said in your original message that you wanted to show the fields if the value is >50K... If you actually want to hide them then replace "display.visible" with "display.hidden", and vice versa.