Skip to main content
stepheng54012748
Known Participant
October 4, 2018
Answered

Javascript writing issue

  • October 4, 2018
  • 1 reply
  • 1001 views

Hello everyone!  It's been quite some time since I've posted a Javascript question.  I've spent hours trying to figure this one out and unfortunately I'm stuck!  If anyone can offer and suggestions/solutions to my isse I would greatly appreciate it.  My goal is simple, writing the code is difficult.  The scenario is:  I have two fields that I'm looking at.  B231 and B232.  If B231 is $10 or less then the answer is $0.  If B232 is $10 or less the answer is $0.  If B231 is greater than $10 then the answer is B231.  If B232 is greater than $10 then the answer is B232.  If either B231 or both are greater than $10 then I need the answer to be the higher of the 2.  I can't figure this out for anything.  I began writing the script but cannot figure out where to go from here.  Hopefully this make sense to someone! 

var theField = this.getField("B231");

var theValue = theField.value;

var theField2 = this.getField("B232");

var theValue2 = theField2.value;

if (theValue <= 10) {

    this.getField("B233").value= 0;

}

else {

     this.getField("B233").value= ();  

}

This topic has been closed for replies.
Correct answer try67

Use this code:

var field1 = this.getField("B231");

var value1 = Number(field1.valueAsString);

var field2 = this.getField("B232");

var value2 = Number(field2.valueAsString);

if (value1<=10 && value2<=10) event.value = 0;

else event.value = Math.max(value1, value2);

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
October 4, 2018

Use this code:

var field1 = this.getField("B231");

var value1 = Number(field1.valueAsString);

var field2 = this.getField("B232");

var value2 = Number(field2.valueAsString);

if (value1<=10 && value2<=10) event.value = 0;

else event.value = Math.max(value1, value2);

stepheng54012748
Known Participant
October 5, 2018

CORRECT ANSWER!  THANK YOU SO MUCH!!!!