• js pdf function to round higher whole number

# js pdf function to round higher whole number

Community Beginner ,
Jun 21, 2022 Jun 21, 2022

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"

TOPICS
JavaScript

Views

23

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Adobe Community Professional , Jun 21, 2022 Jun 21, 2022

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;}

Likes

2 Replies 2
Jun 21, 2022 Jun 21, 2022

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;}

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Jun 21, 2022 Jun 21, 2022

Copied

LATEST

Thank you very much!!!

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources