Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2016-10-17
17
Medium Priority
?
109 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 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
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

*Adobe Acrobat 9 was used for this article. Particular steps may vary depending on software versions. 1. Create a framework of your form in Word, leaving space where you’d ultimately like the Adobe fields to appear.  (Note: I use the blank lines …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this third video of the Xpdf series, we discuss and demonstrate the PDFtoText utility, which converts PDF files into plain text files. Download and install the software.: You may have already downloaded and installed the Xpdf tools while watching…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …

688 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