Skip to main content
Brendon87
Known Participant
April 17, 2018
Answered

Form field javascript

  • April 17, 2018
  • 2 replies
  • 1102 views

Hi, I am very rookie with Java and need a form field to check a condition then return a value, my code looks like this:

OnFocus:

event.value = this.getfield("R_15b").value;

if(event.value < 13){

Event.value = this.getfield("R_18")}

else{event.value = 0}

R_18 is a calculated field and R_15b is an input field both preceding the event however when I tab to the field it seems to pause and run the script but the field does not populate.

Please can someone assist in pointing out my error

Regards

This topic has been closed for replies.
Correct answer try67

Use this code as the custom calculation script of "A":

event.value = (Number(this.getField("B").valueAsString)<=12) ? this.getField("C").valueAsString : 0;

2 replies

Bernd Alheit
Community Expert
Community Expert
April 17, 2018

Use

event.value = this.getfield("R_18").value

not

Event.value = this.getfield("R_18")

try67
Community Expert
Community Expert
April 17, 2018

What are you trying to achieve, exactly?

Brendon87
Brendon87Author
Known Participant
April 17, 2018

What needs to happen is that the event field (field A) looks at a field (field B) and determines if it is less than or equal to 12, if yes, then return the value from a different field (field C), otherwise give zero.

Then there is an additional field that does the same thing but for when its greater than 12.

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 17, 2018

Use this code as the custom calculation script of "A":

event.value = (Number(this.getField("B").valueAsString)<=12) ? this.getField("C").valueAsString : 0;