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.
Set a value, e.g.:
var warranty = 0;
Copy link to clipboard
Copied
Set a value, e.g.:
var warranty = 0;
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.
Copy link to clipboard
Copied
Nevermind !!
Thank you