Expand my Community achievements bar.

help with some basic 'sum' script with 'if'

Avatar

Level 1

hi,

i need to create a 'sum' field that will calculte fieldA*fieldB*fieldC.

fieldA and fieldB are regular numeric fields so sum (fieldA*fieldB) works just fine.

what i need is fieldC to be a radio button, so that when Option1 is checked then multiply by 4, and when Option2 is checked then multiply by 8

how do i do that?

please consider that my scripting knowledge is far less than basic, so be gentle...

tnx

Kobi

4 Replies

Avatar

Level 7

Your calculate script in formcalc could be:

if (fieldC == 1) then

$ = fieldA*fieldB*4

elseif (fieldC == 2) then

$ = fieldA*fieldB*8

endif

just make sure you have "Specify Item Values" checked for your radio buttons under Object > Binding. Also at the moment it will show '0' if none of the buttons are checked so you could put in an 'else' condition if you want it to show something else.

Avatar

Level 1

it worked, many thanks!!!

is there any "formcalc for dummies" i can look at?

Avatar

Level 7

The logic of formcalc is similar to visual basic. The help files that come with LiveCycle are very good for syntax.