You have to understand about the different types of values.
You can have a value that has the type of "string", for example "one".
You can have a value that has the type of "number", for example 1.
You can have a value that has the type of string but looks like a number and under the right circumstance acts like a number, for example "1".
Some sample code:
console.println("A string: " + typeof "one");
console.println ("A number: " + typeof 1);
console.println("A number as a string: " + typeof String(1));
console.println ("A number as a string: " + typeof "1");
console.println ("A string as a number: " + typeof Number("1"));
If you want to test for a null string value or null value for a numeric field you need to the "valueAsString" property. If you just use the "value" property for the field and compare to 0, then null values or null strings will be automatically be converted to zero for the comparison.
One also needs to be careful when adding a group of variables the consist of numbers and nulls since the "+" operator is both the additive operator and the string concatenation operator.
I have a basic understanding of the different types of values and I should not have written zero in my original post as it would be entered 0.
I have read and re-read your answer and I appreciate what you are trying to explain to me but I don’t think I am being clear enough in what I am trying to accomplish.
I don’t think I need to use the valueAsString property because the user would always enter the value as a number – these forms have been used for many years in Excel and they know what to enter. I am not sure if this was unclear.
All of my examples were my feeble attempt to get this calculation to work without listing the answer in every row on the form.
To be more specific about the form, listed below are the fields in the form. Where is says number, it is entered by the user. Where is says calculation, I have created a calculation. The problem I am having is with the Length of Risers Added – each time they check the elevation they do not always add risers. So there will be several entries with a 0 entered and that makes my calculation fail (if i use the "if statement").
Elevation of top of plate as initially installed (number) (entered once)
The following fields are headings and there are 18 rows on the form.
Fill Elevation at riser (number)
Fill Height (calculation)
Length of Risers Added
To Date (calculation)
Elevation at top of riser (number)
Today’s plate elevation (calculation)
Current Settlement (calculation)
Total Settlement (calculation)
If I remove the part:
The formula will work but the problem is the answer will be repeated on every row of the form from that point to the bottom.
I'm sorry if I am not "getting" what you are trying to tell me, I really do want to learn to do this correctly. I do not think I will ever do much more than calculations though and that might be part of the learning problem?
If you want to check any field for a null string that might be formatted as number you should use the "valueAsString" property and compare to the "" value.
Also you should be aware to be able to show leading zeros for the SSN or Zip Code one also needs to use the "valueAsStirng" property or the leading zeros will be lost.