Page 1 of 2

Multiple Colors in Label Component

Posted: Thu Jan 16, 2014 2:58 pm
by Jay6395558

How do I get the message shown in a label to be a certain color based on the result if the if, then statement? Here is my script. I would like the "if" result to be in green and the "else" result to be in red. Right now, both results are shown in the color I set in the components properties.

if (dlam3 && dlam).text(result);


Multiple Colors in Label Component

Posted: Thu Jan 16, 2014 4:34 pm
by Kateryna Grynko

Hi Jay,

This code is incorrect. What exactly do you want to do?

Do you want to set label component text colour depending on variable 'dlam' value? If dlam 3 - then green, else red? Do I understand correctly?


Multiple Colors in Label Component

Posted: Thu Jan 16, 2014 6:35 pm
by Jay6395558

Sorry. The code did not paste properly. Here it is...

if (dlam3 && dlamImage

Image


Multiple Colors in Label Component

Posted: Thu Jan 16, 2014 6:35 pm
by Jay6395558

if (dlam3 && dlam).text(result);


Multiple Colors in Label Component

Posted: Thu Jan 16, 2014 6:36 pm
by Jay6395558

[if (dlam3 && dlam).text(result);]


Multiple Colors in Label Component

Posted: Thu Jan 16, 2014 6:38 pm
by Jay6395558

For some reason the code doesn't paste properly (I've tried it 4 times) so here is a screenshot of the code.
Image


Multiple Colors in Label Component

Posted: Thu Jan 16, 2014 8:13 pm
by Kateryna Grynko

Hi Jay,

Then you can use this code:prevar color = "";
if (dlam 3 && dlam < 10){
result = "In recmmended 3λ to 10λ range";
color = "green";
} else {
result = "Not in recommended 3λ to 10λ range";
color = "red";
}

Appery("mobilelabel_98")&#46;text(result);
Appery("mobilelabel_98")&#46;css("color", color);/pre


Multiple Colors in Label Component

Posted: Thu Jan 16, 2014 8:23 pm
by Jay6395558

That worked perfect! Thanks.


Multiple Colors in Label Component

Posted: Thu Jun 26, 2014 4:44 am
by Tooba Atif

A stupid question may be but I need multiple colors in same label component like Status: Complete will appear in black
If 'Status: Alert' then the "Alert" should appear in red but "Status:" in black etc.
I can do it using grid but is there any other way?


Multiple Colors in Label Component

Posted: Thu Jun 26, 2014 5:08 am
by Yurii Orishchuk

Hi Tooba,

Sorry but i can not understand what problem do you have.

Did you tried solution in above?

You can use a lot of components for this purpose.

And it's up to you what exactly you will choose.

Also please give us screen shots what did you tried so far. And describe on this screen shot what do you expect.

Thanks & regards.