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!
Jeff

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

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

$color_result

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:

if($myresult>100){
$color_result="#ff0000"; //red
}
else{
$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##;"

##myresult##

...

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:

if($GLOBE>$threshold){
$color_result="#ff0000"; //red
}
else{
$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!!

...
List Manager

Build different lists for your site

Buy now!
...
CalcBuilder

Create dynamic calculators

Buy now!