Solved

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

Posted on 2016-10-17
17
97 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

PaperPort is a popular document imaging/management product from Nuance Communications (http://www.nuance.com/). It is in widespread use by both individuals (http://www.nuance.com/for-individuals/by-product/paperport/index.htm) and businesses (http:/…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
We often encounter PDF files that are pure images, that is, they do not have text characters, but instead contain only raster graphics. The most common causes of this are document scanning software and faxing software/services that create image-only…
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…

738 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