Okay, I think you misunderstood what I meant. I understand this is just an example. To illustrate my point, here is an example (based on the one you provided);
If fieldname1 (dropdown field) is ‘A’, the fields that are displayed are fieldname2 and fieldname3.
If fieldname1 (dropdown field) is ‘B’, the fields that are displayed are fieldname4 and fieldname5.
If fieldname1 (dropdown field) is ‘C’, the fields that are displayed are fieldname6 and fieldname7.
The following code doesn’t work properly as only some of the fields will be populated for each dropdown selection (I will probably need to divide the fields in separate if-statements for each dropdown selection):
(function(){
if(AND(fieldname2, fieldname3, fieldname4, fieldname5, fieldname6, fieldname7))
{
if(fieldname1 == "A") return fieldname2+12;
if(fieldname1 == "B") return fieldname2+30;
if(fieldname1 == "C") return fieldname2+54;
}
return '';
})()