Jay6395558
Posts: 0
Joined: Thu Nov 07, 2013 8:17 pm

Multiple Colors in Label Component

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);

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Multiple Colors in Label Component

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?

Jay6395558
Posts: 0
Joined: Thu Nov 07, 2013 8:17 pm

Multiple Colors in Label Component

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

if (dlam3 && dlamImage

Image

Jay6395558
Posts: 0
Joined: Thu Nov 07, 2013 8:17 pm

Multiple Colors in Label Component

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

Jay6395558
Posts: 0
Joined: Thu Nov 07, 2013 8:17 pm

Multiple Colors in Label Component

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

Jay6395558
Posts: 0
Joined: Thu Nov 07, 2013 8:17 pm

Multiple Colors in Label Component

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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Multiple Colors in Label Component

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

Jay6395558
Posts: 0
Joined: Thu Nov 07, 2013 8:17 pm

Multiple Colors in Label Component

That worked perfect! Thanks.

Tooba Atif
Posts: 0
Joined: Fri Apr 04, 2014 3:07 am

Multiple Colors in Label Component

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?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Multiple Colors in Label Component

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.

Return to “Issues”