Advait Kawthalkar
asked on
Change text Colour based on value in another field in pdf forms
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.
Why is there a Neglected mark in the question ???
because nobody add a comment to it after 12h
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.
the value 100 needs to be replaced with your max value:
if (v>100) {event.target.textColor = color.red;}
capt.
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;
the value 100 needs to be replaced with your max value:
if (v>100) {event.target.textColor = color.red;}
capt.
ASKER
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.
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.
Hi
Great that is not a problem. We simply look up the value of the Eligibility Field and use this in the validation.
hth
capt
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;
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
ASKER
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.
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.
can you send the form?
ASKER
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
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
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much Captain for your correct advice, suggestion. It is working now.
Myinfo
Myinfo
Great! Glad I could help.
ASKER
Yes that was uploaded by mistake. Can you delete the question as well as the attachment.
Thank you.
Thank you.
I think the question has good value as formatting guides for conditional field values are scarce.
I vote keep Q but delete attachment.
capt.
I vote keep Q but delete attachment.
capt.
ASKER