Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2016-10-17
17
Medium Priority
?
112 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 31

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 31

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 31

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 31

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 31

Accepted Solution

by:
captain earned 2000 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 31

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 31

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In a previous article published here at Experts Exchange, Signature Image with Transparent Background (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_12380-Signature-Image-with-Transparent-Background.html), I explained how to cre…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
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…
Suggested Courses

971 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