1. There are two errors in line 14:
- quantity is a number, not a field, you should access its value directly, it has no "value" property.
- newName is the name of a field, not an actual Field object.
So replace that line with:
quantity += this.getField(newName).value;
2. If the names of your fields are consistent there's no need to iterate over all the fields in the file. You can access them directly.
You're already doing it with the Price field, so why aren't you doing it with the Quantity field, too?
Thanks for the reply.
1) It still seems to be putting out an error in that field with the updated code:
2) The reason is that each product could have between 1 to 8 quantities. So I though it easiest to iterate over all fields to get this rather than manually specify how many of each quantity a product has.
1. The field name you specified is incorrect.
2. Then just run a loop from 1 to 8. There's really no need to iterate over all the fields in the file.