0
Participant
,
/t5/acrobat-discussions/javascript-variable-undefined-please-help/td-p/11927351
Mar 25, 2021
Mar 25, 2021
Copy link to clipboard
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?
Thanks in advance.
Cheers.
TOPICS
Create PDFs
,
Edit and convert PDFs
,
General troubleshooting
,
How to
,
JavaScript
,
PDF forms
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 ACCEPTED SOLUTION
Community Expert
,
/t5/acrobat-discussions/javascript-variable-undefined-please-help/m-p/11927690#M305178
Mar 26, 2021
Mar 26, 2021
Copy link to clipboard
Copied
Set a value, e.g.:
var warranty = 0;
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
/t5/acrobat-discussions/javascript-variable-undefined-please-help/m-p/11927690#M305178
Mar 26, 2021
Mar 26, 2021
Copy link to clipboard
Copied
Set a value, e.g.:
var warranty = 0;
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Flynn0101
AUTHOR
Participant
,
/t5/acrobat-discussions/javascript-variable-undefined-please-help/m-p/11928062#M305197
Mar 26, 2021
Mar 26, 2021
Copy link to clipboard
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Flynn0101
AUTHOR
Participant
,
LATEST
/t5/acrobat-discussions/javascript-variable-undefined-please-help/m-p/11928072#M305198
Mar 26, 2021
Mar 26, 2021
Copy link to clipboard
Copied
Nevermind !!
Thank you
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

