Skip to main content
Inspiring
July 14, 2020
Question

two codes

  • July 14, 2020
  • 2 replies
  • 576 views

Can someone pls help.

event.value = Number(this.getField("num1").valueAsString)*7 + "%";
event.value = Number(this.getField("num2").valueAsString)*7 + "%";

Only the second code is working but I need both of them to work,if value is changed in "num1" field I need first code to activate and if value is changed in "num2" field I need second code to activate.

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
July 14, 2020

The second line will overwrite the result of the first one. In order to do what you describe you need to move your code to the validation scripts of the "num1" and "num2" fields.

Asim123Author
Inspiring
July 14, 2020

That wouldn't work.I have 2 buttons,but1 activate num1 and but2 activate num 2 and result from num1 and num 2 is showed in textfield (t1) but they can't overwrite one another they need to add to same field,(example: but1 activate num1 which add 4 to t1 but2 activate num2 which also add 4 to t1 which now show 8.thats why I need both of the codes to work at same time cuz I use that code on t1 field as custom validation.

Asim123Author
Inspiring
July 14, 2020

Thx guys for help I figure it out with this code that was lucky guess cuz I don't know anything about coding.

event.value = Number(this.getField("num1").valueAsString)*7 + Number(this.getField("num2").valueAsString)*11;

 

Legend
July 14, 2020

You mean, you want a change in num1 to cause it to completely ignore num2, unless someone later changes num2, in which case it will ignore num1? That's very unusual and certainly can't be done from a calculation field. You'd need to trigger actions as num1 and num2 are changed.

Asim123Author
Inspiring
July 14, 2020

num1 and num 2 is not important I just wanna know if it's possible for both codes to work their job at the same time and how to make it do that?