Participant ,
Mar 25, 2021 Mar 25, 2021

Copied

Hello!
I'm working on a section in my code that finds a number in a field (Total+(parseInt(idx)+2) and depending on that number change the value of another field (Total+(parseInt(idx)+3)

Code here:

``````  function SetTotalValues(cID, idx) {
this.getField("Total"+(parseInt(idx)+1)).value = 0.2 * this.getField("Total"+(parseInt(idx))).value;
this.getField("Total"+(parseInt(idx)+2)).value = this.getField("Total"+(parseInt(idx))).value + this.getField("Total"+(parseInt(idx)+1)).value;

var getValue = [
[3300, 194.25],
[4000, 197.5],
[238000, 1286.3],
[Infinity, 999999],
];
var warranty;
var i;
for (i = 0; i < getValue.length; i++) {
if ((this.getField("Total"+(parseInt(idx)+2)).value) > (getValue[i][0]) && (this.getField("Total"+(parseInt(idx)+2)).value) <= (getValue[i+1][0])){
warranty = (getValue[i][1]);
}
}
this.getField("Total"+(parseInt(idx)+3)).value = warranty;
}``````

The problem is that the warranty is undefined, I spent ages troubleshooting. Can someone help?

Cheers.

TOPICS
Create PDFs, Edit and convert PDFs, General troubleshooting, How to, JavaScript, PDF forms

Views

5.2K

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 , Mar 26, 2021 Mar 26, 2021
Set a value, e.g.:var warranty = 0;

Likes

3 Replies 3
Mar 26, 2021 Mar 26, 2021

Copied

Set a value, e.g.:
var warranty = 0;

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
Participant ,
Mar 26, 2021 Mar 26, 2021

Copied

@Bernd Alheit
Changing the variable to 0 changes it to zero,

it should be running through this condition and it's not working.

``````var i;
for (i = 0; i < getValue.length; i++) {
if ((this.getField("Total"+(parseInt(idx)+2)).value) > (getValue[i][0]) && (this.getField("Total"+(parseInt(idx)+2)).value) <= (getValue[i+1][0])){
warranty = (getValue[i][1]); ``````

any ideas?

Thanks for the help.

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
Participant ,
Mar 26, 2021 Mar 26, 2021

Copied

Nevermind !!

Thank you

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