Skip to main content
Participating Frequently
April 13, 2019
Answered

how to change colour in app.responses for example if contain "B" then the input text will be in colour blue or "O" will be in colour orange, is anyone can help

  • April 13, 2019
  • 2 replies
  • 1726 views

I would like to create a dynamic stamp something like this, as long as the second field contain "B" then the first and second field text will change to colour blue or if contain "O" then will be colour orange.

is there anyone can give me some advise how to achieve this goal, since I am very green in Javascript.

many thanks

ado

This topic has been closed for replies.
Correct answer try67

thank you

what if the cMsg just contain "o", because may input O1, or O2... would cMsg== "O" work?

thanks again


No. To check for that use:

if (/o/i.test(cMsg))

2 replies

Participating Frequently
April 13, 2019

yes you right I missing statement,

the correct one is follow:-

first field

var cAsk = "input Sh" ;

var cTitle = "Table";

if(event.source.forReal && (event.source.stampName == "#Ao-bX_USVdL6_dk0gBSz6C"))

{

  var cMsg = app.response(cAsk, cTitle);

  event.value = cMsg;

event.source.source.info.exhibit = cMsg;

}

second field

var cAsk = "input colour code" ;

var cTitle = "Table";

if(event.source.forReal && (event.source.stampName == "#Ao-bX_USVdL6_dk0gBSz6C"))

{

  var cMsg = app.response(cAsk, cTitle);

  event.value = cMsg;

event.source.source.info.exhibit = cMsg;

}

sorry for the confusion. :-(

try67
Community Expert
Community Expert
April 13, 2019

OK, that makes more sense. The next step would be to add something like this to your code:

if (cMsg=="O") event.target.textColor = color.yellow;

else if (cMsg=="B") event.target.textColor = color.blue;

else event.target.textColor = color.black;

Participating Frequently
April 13, 2019

thank you for your reply

will this statement also work for first field, because the second field determent the colour?

thanks

try67
Community Expert
Community Expert
April 13, 2019

Were you able to create a dynamic stamp that does all of it, except for the coloring? If so, how is the user inputting the values of the fields?

try67
Community Expert
Community Expert
April 13, 2019

Also, your question is not very clear... Are you trying to change the color in the app.response window, or in the stamp itself?

The former is not possible.

Participating Frequently
April 13, 2019

just the stamp text change colour

thanks