Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Calculation

Avatar

Level 2
Can any great genius pls help me out on this?<br /><br />I have a radio button with options of selecting a 5% or 10% discount and a Total Price numeric field.<br /><br />I need help in creating a script for:<br /><br />If Radio Button is selected then<br />Total Price = Sum(a,b,c) <already on FormCalc/Calculate Event> * Price Discount <radio Button in ExclGroup><br /><br />Please help... i've been working on it for days...
5 Replies

Avatar

Level 4
Hi Win,



Can't you make an if-statement to see wich rdo is selected and then calculate that discount?



Regards,

Avatar

Level 2
Hi Ronny,<br />I'm sorry i guess i'm too new to have understand your question to script on the above.<br /><br />Currently, i have a Total Price field at calculate event on <FormCalc>with the following:<br /><br />$.rawValue = Sum (a,b,c) * Prem: computation is accurate but Total Price is not reflected in the field when the Discount <Radio button> is not selected.<br /><br />So when i transform the script language to Javascript, it doesn't work at all.<br /><br />So i want the premium to be reflected even when radio button is not selected and then calculate the actual Total Price when form filler selects the type of discount.<br /><br />Can you help on this?

Avatar

Level 4
Hi Win,



I created a sample below is the formcalc script I have on the calculate-event of the Total-field.



if (rdoDiscount.rawValue eq "5") then

$ = (Sum(numVal[*]) * (5/100)) + Sum(numVal[*]);

elseif (rdoDiscount.rawValue eq "10") then

$ = (Sum(numVal[*]) * (10/100)) + Sum(numVal[*]);

elseif (rdoDiscount.rawValue eq "15") then

$ = (Sum(numVal[*]) * (15/100)) + Sum(numVal[*]);

else

$ Sum(numVal[*]);

endif



For the rest I have two value fields (both named numVal)

and three radiobuttons with the value specified in the Binding properties.



If you would like the sample I can mail it to you.



Regards,



RonnyR

Avatar

Former Community Member
Hi,

I think that a good solution could be use a drop-down-list (if you can)

In his Exit event you can call a function to whom pass the value selected.





obviously the function makes the calculations you want.



No "if" statement and better maintenance of the code :-)



I hope this helps.



Roberto Bellarmino

Avatar

Level 2
Dear Ronny,

Thanks so much.



Yes, maybe if you can mail me the sample for a better reference.

Sorry for the trouble.



Regards,

Win