• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

js pdf function to round higher whole number

Participant ,
Jun 21, 2022 Jun 21, 2022

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?

TOPICS
JavaScript

Views

183

Translate

Translate

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 guidelines

correct answers 1 Correct answer

Community Expert , 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;}

Votes

Translate

Translate
Community Expert ,
Jun 21, 2022 Jun 21, 2022

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

Votes

Translate

Translate

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 guidelines
Participant ,
Jun 21, 2022 Jun 21, 2022

Copy link to clipboard

Copied

LATEST

Thank you very much!!!

Votes

Translate

Translate

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 guidelines