Solved

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

Posted on 2016-10-17
17
64 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
Comment Utility
Why is there a Neglected mark in the question ???
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
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
Comment Utility
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
 

Author Comment

by:Advait Kawthalkar
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
can you send the form?
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:Advait Kawthalkar
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you very much Captain for your correct advice, suggestion. It is working now.

Myinfo
0
 
LVL 30

Expert Comment

by:captain
Comment Utility
Great! Glad I could help.
0
 

Author Comment

by:Advait Kawthalkar
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Update 21-May-2015: I temporarily removed the source code to make major changes to the program. Regards, Joe In a previous Experts Exchange article, How To Rename-Move a Batch of PDF Files Based on Contents of the Files (http://www.experts-exchan…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

772 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

9 Experts available now in Live!

Get 1:1 Help Now