• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Apr 12, 2019 Apr 12, 2019

Copy link to clipboard

Copied

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

TOPICS
Acrobat SDK and JavaScript , Windows

Views

842

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 13, 2019 Apr 13, 2019

No. To check for that use:

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

Votes

Translate

Translate
Community Expert ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

just the stamp text change colour

thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

this are my stamp script

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.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.source.source.info.exhibit = cMsg;

}

after input the colour code "B" the stamp colour will change to colour blue, the first field also change to blue, just like the picture I attached in the post.

many thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

Where does you fill the form fields?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

first field will be on "1"

second field will be on "B"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

Yes, but in the code you posted the value is never copies to the field...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

sorry I do not understanding what you mean?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

The code you posted will populate any field. You left out the command that does so.

It would be something like:

event.value = cMsg;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

yes, I created the stamp,but I just don't know how to change the colour for the text

thanks for your help

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

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. 😞

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

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;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

thank you for your reply

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

thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

That code will only affect the main field, the one triggering the calculate event, but you can easily apply the same for others.

For example:

var otherField = this.getField("Name of other field");

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

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

otherField.textColor = color.black;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

thank you

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

thanks again

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

No. To check for that use:

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

LATEST

WOW !! Thank you so much it work so good, this is exactly what i am look for.

thank you for helping me to achieve this goal and I learn alot too

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2019 Apr 13, 2019

Copy link to clipboard

Copied

The first field I can not get it to work

var cAsk = "input Sh" ;

var cTitle = "Table";

if(event.source.forReal && (event.source.stampName == "#JwM0QVfkrXapNXl01OFT1C"))

{

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

event.value = cMsg;

var otherField = this.getField("second");

if (cMsg=="r") otherField.textColor = color.red;

else otherField.textColor = color.black;

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

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines