Copy link to clipboard
Copied
Hi
I ask you kindly if anyone can help me build this function
I have 3 fields:
Field 1 = "TYPE OF RATE"
Field 2 = "EURIBOR"
Field 3 = "DURATION IN YEARS"
In field 1 I can write "FIXED RATE" or "VARIABLE RATE".
In field 3 I can write the number of years (10, 12, 15, 18 etc.)
if in field 1 I write "FIXED RATE" I want the text "EURIRS YEARS" + the number indicated in field 3 rounded to the next whole number 5 to appear in field 2.
For example, if I write 12, it must be rounded to 15, if I write 18, it must be rounded to 20 etc
I tried to write this function on validation
if (event.value == "FIXED RATE") {this.getField ("TYPE OF RATE"). value = "FIXED RATE"; this.getField ("EURIBOR"). value = "EURIRS YEARS" + Math.ceil ( this.getField ("DURATION IN YEARS"). value, 5);}
Obviously it doesn't work
It gives me this result
"EURIRS YEARS 0"
Please, can anyone help me?
Use this:
var y = Number(this.getField("DURATION IN YEARS").value);
var x = Math.round((y%5)?y-y%5+5:y);
if (event.value == "FIXED RATE") {
this.getField ("TYPE OF RATE").value = "FIXED RATE";
this.getField ("EURIBOR"). value = "EURIRS YEARS " + x;}
Copy link to clipboard
Copied
Use this:
var y = Number(this.getField("DURATION IN YEARS").value);
var x = Math.round((y%5)?y-y%5+5:y);
if (event.value == "FIXED RATE") {
this.getField ("TYPE OF RATE").value = "FIXED RATE";
this.getField ("EURIBOR"). value = "EURIRS YEARS " + x;}
Copy link to clipboard
Copied
Thank you very much!!!