Solved

Change text Colour based on value in another field in pdf forms

Posted on 2016-10-17
17
78 Views
Last Modified: 2016-11-02
I have a form where user have an Eligibility amount and the amount they claim for their mobile expense. What I intend to do is validate the field "Amount" such that if the amount field exceeds the amount in "Eligibility Amount" field, the text inside the Amount field should turn red or the entire field area of Amount turns red. This indicates that user is asking more amount then he is eligible for.
0
Comment
Question by:Advait Kawthalkar
  • 7
  • 6
17 Comments
 

Author Comment

by:Advait Kawthalkar
ID: 41847599
Why is there a Neglected mark in the question ???
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41847709
Why is there a Neglected mark in the question ???

because nobody add a comment to it after 12h
0
 
LVL 30

Expert Comment

by:captain
ID: 41848194
Ok a few more seconds :D

Here is a script that needs to go into the validation script of the field. It will change the field colour if a value is exceeded.

var v = Number(event.value);
if (v>100) {event.target.textColor = color.red;}
else event.target.textColor = color.black;

Open in new window


the value 100 needs to be replaced with your max value:
if (v>100) {event.target.textColor = color.red;}

capt.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:Advait Kawthalkar
ID: 41849520
Hello Captain,

The script should take value which is there in the Eligibility field. This value vary from users to users. So there cannot be a max value. What I want is whatever value is there in Eligibility field, if the value in Amount field exceeds that; it should turn red.
0
 
LVL 30

Expert Comment

by:captain
ID: 41850004
Hi

Great that is not a problem. We simply look up the value of the Eligibility Field and use this in the validation.

var v = Number(event.value);
var elg =  this.getField("Eligibility").value;
if (v>elg) {event.target.textColor = color.red;}
else event.target.textColor = color.black;

Open in new window

Assuming the field is called "Eligibility" you can use the code above, if it is called something else just substitute the field name keeping the quotation marks intact.

hth
capt
0
 

Author Comment

by:Advait Kawthalkar
ID: 41851836
Hello Captain,

I substituted the field name but it is not working. I put the above script in my "Amount" field where in the user puts his claim amount. If the user puts more amount then his Eligibility is the amount should turn red. But some how its not working.

Can you help.
0
 
LVL 30

Expert Comment

by:captain
ID: 41852506
can you send the form?
0
 

Author Comment

by:Advait Kawthalkar
ID: 41853155
Hi Captain,

Attached is the form. Select any name from the drop down and it will auto populate the Eligibility & other fields. Below if user claims more amount than that in the E legibility Amount, the Claim amount should turn red. Put some numbers in the Bill Amount and Personal Amount. The Claim amount will be auto calculated. Try putting more amount then the Eligibility amount.

Thanks.
Mobile-Reimbursement-Form.pdf
0
 
LVL 30

Expert Comment

by:captain
ID: 41853684
The script works in your file but it does not update when values are changed for different people with different entitlements. This is the order of calculations that is causing this.

I will need to look into this further to make sure this works as intended.

You should also include a Reset Form button to avoid legacy data to be stored if you intend to have people save local copies. To do this just a button and then name it Rest form. In Properties go to the Action tab an ad the 'reset form' action

For info, I have asked the mods to remove your attachment because the company date that you crossed out is visible. Use redaction to obfuscate if you post sensitive data.
0
 
LVL 30

Accepted Solution

by:
captain earned 500 total points
ID: 41853735
Ok I would make the following changes

The script seems to work fine.

On the Name select Dropdown I would add the action "Mouse Down" >>> Reset Form and select the fields:
SrRow1
SrRow2
ParticularsRow 1
ParticularsRow 2
CA
BAR1
BAR2
PAR1
PAR2

This will take care of the reset for the form data that is unique per claim and also remove any issue of marking the entitlement red even if the value is above the claimed value.

Validation script is (unchanged):
var v = Number(event.value);
var elg =  this.getField("Eligibility Amount").value;
if (v>elg) {event.target.textColor = color.red;}
else event.target.textColor = color.black;

Open in new window


The calculation order is fine.

I would also make the Print a "Mouse Up" action instead of "Mouse Enter" as the dialog just jumps up when the pointer enters the button otherwise, even by accident.

Your amount fields need currency or number formatting.

capt.
0
 

Author Closing Comment

by:Advait Kawthalkar
ID: 41854825
Thank you very much Captain for your correct advice, suggestion. It is working now.

Myinfo
0
 
LVL 30

Expert Comment

by:captain
ID: 41856876
Great! Glad I could help.
0
 

Author Comment

by:Advait Kawthalkar
ID: 41861483
Yes that was uploaded by mistake. Can you delete the question as well as the attachment.

Thank you.
0
 
LVL 30

Expert Comment

by:captain
ID: 41861879
I think the question has good value as formatting guides for conditional field values are scarce.

I vote keep Q but delete attachment.

capt.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever come up with a need of emailing only few pages of PDF file to one of yourfriend or colleague, instead of whole Adobe file? If yes, then surely you have face problems in doing that! Read this section as I have suggested multiple solutio…
This article discusses how to create an extensible mechanism for linked drop downs.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now