Skip to main content
Participating Frequently
February 20, 2025
解決済み

make a selection in a drop down field based on the value of two other field numbers

  • February 20, 2025
  • 返信数 2.
  • 904 ビュー

I have a drop down field (A or B) that needs to be selected based on the value of two other fields

 

if C > D Dropdown = A

If C < D Drowpdown = B

 

How can I write this?

I am definitely new to this and have googled quite a few other answers, but this one is hard to narrow down. 

Thx in advance

解決に役立った回答 try67

Thanks to you both. I got the form updated and checked and it is working perfectly for what i need! 

 

One last thing. Is there a way to make the words show up in a certain color? Green for Accept - Red for Reject?


Yes. Replace this line:

event.value = (numC >= numD) ? "Accept" : "Reject";

 

With:

 

if (numC >= numD) {
	event.value = "Accept";
	event.target.textColor = color.green;
} else { 
	event.value = "Reject";
	event.target.textColor = color.red;
}

返信数 2

try67
Community Expert
Community Expert
February 20, 2025

What should the field's value be if C equals D?

Participating Frequently
February 20, 2025

a = Accept

b = Reject

c = MaxGrossRent

d = GrossRent

 

 

GrossRent>MaxGrossRent=Accept

GrossRent<MaxGrossRent=Reject

Participating Frequently
February 20, 2025

My bad. if C=D it is Accept

 

GrossRent=>MaxGrossRent=Accept

GrossRent<MaxGrossRent=Reject

Nesa Nurani
Community Expert
Community Expert
February 20, 2025

You could use a text field instead of dropdown if you only have two values "A" and "B", and use this as custom calculation script of that text field:

var c = this.getField("C").valueAsString;
var d = this.getField("D").valueAsString;

if (c && d) {
 var numC = Number(c);
 var numD = Number(d);

 if (!isNaN(numC) && !isNaN(numD)) {
  event.value = numC > numD ? "A" : numC < numD ? "B" : "";}} 
else {
 event.value = "";}
Participating Frequently
February 20, 2025

I udated the letters to match the box names and copied this into the script box and it said:

syntaxError: missing ; before statement 5: at line 6