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

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

153

Likes

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

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

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

154

Likes

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
Apr 12, 2019 0
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?

Likes

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
Reply
Loading...
Apr 13, 2019 0
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.

Likes

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
Reply
Loading...
Apr 13, 2019 0
Apr 13, 2019

Copy link to clipboard

Copied

just the stamp text change colour

thanks

Likes

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
Reply
Loading...
Apr 13, 2019 0
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

Likes

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
Reply
Loading...
Apr 13, 2019 0
Apr 13, 2019

Copy link to clipboard

Copied

Where does you fill the form fields?

Likes

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
Reply
Loading...
Apr 13, 2019 0
Apr 13, 2019

Copy link to clipboard

Copied

first field will be on "1"

second field will be on "B"

Likes

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
Reply
Loading...
Apr 13, 2019 0
Apr 13, 2019

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Apr 13, 2019 0
Apr 13, 2019

Copy link to clipboard

Copied

sorry I do not understanding what you mean?

Likes

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
Reply
Loading...
Apr 13, 2019 0
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;

Likes

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
Reply
Loading...
Apr 13, 2019 0
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

Likes

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
Reply
Loading...
Apr 13, 2019 0
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. 😞

Likes

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
Reply
Loading...
Apr 13, 2019 0
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;

Likes

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
Reply
Loading...
Apr 13, 2019 0
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

Likes

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
Reply
Loading...
Apr 13, 2019 0
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;

Likes

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
Reply
Loading...
Apr 13, 2019 0
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

Likes

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
Reply
Loading...
Apr 13, 2019 0
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;

}

Likes

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
Reply
Loading...
Apr 13, 2019 0
Apr 13, 2019

Copy link to clipboard

Copied

No. To check for that use:

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

Likes

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
Reply
Loading...
Apr 13, 2019 0
Apr 13, 2019

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Apr 13, 2019 0