Copy link to clipboard
Copied
var total
{
for(i2 = 0; i2 < 18; i2++)// Itteration through Lines
{
var itemVolume = String(this.getField('105' + 'Qu' + i2).valueAsString); // Declares Item volume variable and targets each lines volume field
if(itemVolume > 0)// Checks for values of 1 or greater
console.println(itemVolume)
{
total + (this.getField('105' + 'Pri' + i2)).valueAsString;
this.getField("105Total").valueAsString = total
}
}
}
My Field names are 105PriX and 105QuX X being 0-18 It is currently just setting my total field to the word [Object Field] if im not mistaken i should be solving that with .valueAsString? Would appreciate any and all help thank you very much!
Copy link to clipboard
Copied
You doesn't you set any value for total.
Copy link to clipboard
Copied
Total is being set based off the values of (this.getField('105' + 'Pri' + i2) do i need to set it to 0 to start with?
Copy link to clipboard
Copied
When i try setting a value for total other than the total + (this.getField('105' + 'Pri' + i2)).valueAsString; it just over rides me trying to set the value in the loop and will return whatever i set the value to.
Copy link to clipboard
Copied
Try this:
total = total + Number(this.getField('105' + 'Pri' + i2).valueAsString);
Copy link to clipboard
Copied
Awesome thank you very much solved one problem only thing is now it keeps building up the total variable every time i run the program Would it be better to set total to 0 outside of the loop so it resets once it finishes my for loop? Or would it be better to have a clear button that sets total to 0? Sorry started this project months ago so a little rusty on js thanks for the help!
Copy link to clipboard
Copied
For the loop use:
var total = 0;