CalcBuilder Forum

Conditional field (colors)

User lafra002 2017-07-05 12:58:58

Hi, have been using your component several times, really great!

I do have a question, I have an excel sheet, and based upon the result of a calculation, the output is in red color or green color. How do I translate this to the component?

Thanks in advance!

Moonsoft support 2017-07-05 15:56:00

the simplest solution would be to create an additional result, let's call it


so you will set it to the right css color value. At the code you can set the desired value using conditional expressions or any other structure needed, for ex:

$color_result="#ff0000"; //red
$color_result="#0000ff"; //blue

at the output section you can use this new result to set the style of that specific section, that you can place inside a span, div, etc

span style="color:##color_result##;"



If you're using extended version and the excel mapping instead of the code, you can map another result to one additional cell, that will contain color value same as above, calculated with excel if expressions as well.

Hope this helps, regards

User lafra002 2017-07-25 18:31:07

Thanks for your quick reply.

I understand your explanation. Only thing is; where do I put that code? In Javascripts events, Executed after calculation?

Because my code would be like this:

$color_result="#ff0000"; //red
$color_result="#008000"; //green

Only if the calculated Globe-score is higher than the threshold (also calculated based upon other variables); it would have to turn red.

User lafra002 2017-07-25 19:00:10

Sorry, managed to find it and get it working. Thanks!!

Support/development 40 hours

With the peace of mind of having a professional team at your service (20% discount)

Buy now!

Create dynamic calculators

Buy now!