Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Change field color
  FAQ FAQ  Forum Search   Register Register  Login Login


Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

Change field color

 Post Reply Post Reply Page  12>
Author
Maureen View Drop Down
New Member
New Member


Joined: 09 Jun 2015
Location: Netherlands
Points: 24
Post Options Post Options   Quote Maureen Quote  Post ReplyReply Direct Link To This Post Topic: Change field color
    Posted: 28 Jul 2015 at 10:02pm
Hello,

Can somebody help me with a javascript for this this: I've a field with a calculation value. If the value is negative  it must shown like -123 in red. Or the color of the field must change in red

Thanks in advanced

Maureen
Back to Top
Sponsored Links


Back to Top
try67 View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 628
Post Options Post Options   Quote try67 Quote  Post ReplyReply Direct Link To This Post Posted: 28 Jul 2015 at 11:48pm
You can change the field's color like this:
event.target.textColor = color.red;
Or:
event.target.textColor = color.black;
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com
Back to Top
Maureen View Drop Down
New Member
New Member


Joined: 09 Jun 2015
Location: Netherlands
Points: 24
Post Options Post Options   Quote Maureen Quote  Post ReplyReply Direct Link To This Post Posted: 29 Jul 2015 at 10:35am
Thanks for your reply, but how can I do it if the field value is negative. So of the field value is a negative value, then the color of the number must change in red. If the value is positive the color stay black
Back to Top
try67 View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 628
Post Options Post Options   Quote try67 Quote  Post ReplyReply Direct Link To This Post Posted: 29 Jul 2015 at 10:40am
if (event.value<0) event.target.textColor = color.red;
else event.target.textColor = color.black;
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com
Back to Top
Maureen View Drop Down
New Member
New Member


Joined: 09 Jun 2015
Location: Netherlands
Points: 24
Post Options Post Options   Quote Maureen Quote  Post ReplyReply Direct Link To This Post Posted: 29 Jul 2015 at 11:55am
It doesn't work :(. Maybe I didn't explane it right. In the simplified field notation I've this calcultion:

field1-field2=field3

I've set your javascript in Custom calculation field. But then it overrules the simplified notation calculation and nothing happens then

What I want in field3 is a script to to this:
field1-field2. If the outcome is a negative value, then the color should be red.
(1-2=-3, so -3 should be in red)

Hope you can help


Back to Top
try67 View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 628
Post Options Post Options   Quote try67 Quote  Post ReplyReply Direct Link To This Post Posted: 29 Jul 2015 at 12:51pm
Put it in the custom validation script, then.
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com
Back to Top
Maureen View Drop Down
New Member
New Member


Joined: 09 Jun 2015
Location: Netherlands
Points: 24
Post Options Post Options   Quote Maureen Quote  Post ReplyReply Direct Link To This Post Posted: 29 Jul 2015 at 2:21pm
still not working :)
Back to Top
try67 View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 628
Post Options Post Options   Quote try67 Quote  Post ReplyReply Direct Link To This Post Posted: 29 Jul 2015 at 2:24pm
Works fine for me: https://www.dropbox.com/s/gyobr7j37p2kw4z/Subtraction%20test.pdf?dl=0
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com
Back to Top
Maureen View Drop Down
New Member
New Member


Joined: 09 Jun 2015
Location: Netherlands
Points: 24
Post Options Post Options   Quote Maureen Quote  Post ReplyReply Direct Link To This Post Posted: 29 Jul 2015 at 2:46pm
I can see yes, Wonder why it's not working for me. What is the exact script you've in the third field?
Back to Top
try67 View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 628
Post Options Post Options   Quote try67 Quote  Post ReplyReply Direct Link To This Post Posted: 29 Jul 2015 at 2:51pm
Exactly the same one I gave you... See the field's Validation tab.
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com
Back to Top
Maureen View Drop Down
New Member
New Member


Joined: 09 Jun 2015
Location: Netherlands
Points: 24
Post Options Post Options   Quote Maureen Quote  Post ReplyReply Direct Link To This Post Posted: 29 Jul 2015 at 3:19pm
In the validation tab I now have:
var v1 = getField("Field1").value;
var v2 = getField("Field2").value;
event.value = v1 - v2;
if (event.value<0) event.target.textColor = color.red;
else event.target.textColor = color.black;

But still not workingCry
Back to Top
 Post Reply Post Reply Page  12>
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.047 seconds.