Skip to main content
Inspiring
August 24, 2020
Beantwortet

Need help (javascript)

  • August 24, 2020
  • 4 Antworten
  • 809 Ansichten

Hi, I have this code:

If(this.getField("field1").value <5){

event.value = 1000;}

Field1 need to  increase  by 5 (value<10,value<15,value<20...etc)up to 200 and event. value will decrease by 10 every time. Is there a way to do it without making really long code? 

Dieses Thema wurde für Antworten geschlossen.
Beste Antwort von try67

You can do it using this code:

 

event.value = 1000 + (Math.floor(Number(this.getField("field1").valueAsString)/5)*10);

4 Antworten

try67
Community Expert
try67Community ExpertAntwort
Community Expert
August 24, 2020

You can do it using this code:

 

event.value = 1000 + (Math.floor(Number(this.getField("field1").valueAsString)/5)*10);

ls_rbls
Community Expert
Community Expert
August 24, 2020

I was checking out the script and I wasn't able to figure out how to increase all the way up to 200.

 

The user wanted Field1 need to  increase  by 5 (value<10,value<15,value<20...etc)up to 200 "

 

 I'm guessing if it would be convenient to use this script as a custom validation script with a condition to stop the increments when a total value of 200 has been reached?

Technical Generalist