Calculation validation script based on radio button and checkbox
I would like help with the following please:
- Radio button group 'Soort' existing of options 'New' and 'Damaged'.
- When 'Damaged' is selected, 4 checkboxes appear: 'VZ', 'AZ', 'BZ', 'PZ'.
- When for instance 'VZ' is selected, checkboxes 'V1', 'V2', and 'V3' appear, each containing a different value. Same for 'AZ' ('A1', 'A2', ...) and the other ones.
- 'Total' is the field for the result of the calculation, based on the input.
When 'New' is selected the calculated value of 'Total' must be overwritten with value '795', otherwise the values of 'V1', 'V2', 'V3', 'A1', 'A2', and so on must be added up to 'Total'.
I currently have place this script to the 'Total' field (tab Calculate, alternate calulated script), but keep getting errors when 'Damaged' is selected (possibly because the underlying options are not selected yet?):
var soort = this.getField("Soort").valueAsString;
if (soort=="New") { event.value = "795"; }
else if (soort=="Damaged")
{ var v1=this.getField("V1").value;
var v2=this.getField("V2").value;
var v3=this.getField("V3").value;
var v4=this.getField("V4").value; //and so on...
event.value = 0+v1+v2+v3+v4; }
