Hi,
after searching hours - can't find the bug.
I have multiple fields calculating a hectare value out of the input value.
Therefor i have:
- One field hectare total
- Multiple fields you can type in a percentage - the result will be in hectare.
Each of these multiple fields is formatted with 2 decimal places (Format tab). Following script is appliad to each field:
// get field values
var a1 = this.getField("totalHa").value;
var a2 = this.getField("currentFieldName".value;
// get percentage for current field
var result1 = a1 / 100 * b1;
// decimal correction for math.floor
decResult1 = Math.floor (result1 * 100);
// get the correct decimal back and put it into the field
event.value = (decResult1/100);
---------------
Now... this all works perfect - but only for one field. I used this code for every field but changed the variable number "1" to "2"...(only to eliminate errors...)
BUT: When i put a value in field one it will show correct. When i put a value in field two the value in field one vanishes and the correct value of field two appears... and so on. Is there a problem with event.value for multiple fields? Is there an alternative for populating a field with the result?
Kind regards
Christoph Busch
What you can do, is consolidate all your calculations into one single script, and you may assign that script even to a hidden field with no connection at all to the other fields. In fact, this would also speed up your form, and, of course, it gives you much more control over the calculations.
Hope this can help.
Max Wyss.