Skip to main content
Brendon87
Known Participant
April 17, 2018
解決済み

Form field javascript

  • April 17, 2018
  • 返信数 2.
  • 1115 ビュー

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

このトピックへの返信は締め切られました。
解決に役立った回答 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

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
Brendon87作成者
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 Expert解決!
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;