Print Page | Close Window

Change text color based on a calculated value

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
URL: http://forums.planetpdf.com/forum_posts.asp?TID=1116
Printed Date: 29 Mar 2020 at 11:24pm
Software Version: Web Wiz Forums 11.10 - http://www.webwizforums.com


Topic: Change text color based on a calculated value
Posted By: bdavis
Subject: Change text color based on a calculated value
Date Posted: 21 Feb 2014 at 5:38pm
Hello everyone,

I've created a claim form which should be filled out on the computer, but some people insist on printing it out and filling it out by hand.

There are 11 fields for individual claims (TotalClaimed1 through TotalClaimed11), and they are all totaled in another field (FSA_Total)

I've set the FSA_Total text color to default to white, so if it is printed, it appears blank, instead of showing 0.00. I would like to change the text to black is the value in FSA_Total is not zero.

Here is the custom calculation script:



var claim1 = this.getField('TotalClaimed1'),
    claim2 = this.getField('TotalClaimed2'),
    claim3 = this.getField('TotalClaimed3'),
    claim4 = this.getField('TotalClaimed4'),
    claim5 = this.getField('TotalClaimed5'),
    claim6 = this.getField('TotalClaimed6'),
    claim7 = this.getField('TotalClaimed7'),
    claim8 = this.getField('TotalClaimed8'),
    claim9 = this.getField('TotalClaimed9'),
    claim10 = this.getField('TotalClaimed10'),
    claim11 = this.getField('TotalClaimed11'),
    fsabox = 0;

if (this.getField('Group1').value == 'FSA') {
    fsabox += claim1.value;
}
if (this.getField('Group2').value == 'FSA') {
    fsabox += claim2.value;
}
if (this.getField('Group3').value == 'FSA') {
    fsabox += claim3.value;
}
if (this.getField('Group4').value == 'FSA') {
    fsabox += claim4.value;
}
if (this.getField('Group5').value == 'FSA') {
    fsabox += claim5.value;
}
if (this.getField('Group6').value == 'FSA') {
    fsabox += claim6.value;
}
if (this.getField('Group7').value == 'FSA') {
    fsabox += claim7.value;
}
if (this.getField('Group8').value == 'FSA') {
    fsabox += claim8.value;
}
if (this.getField('Group9').value == 'FSA') {
    fsabox += claim9.value;
}
if (this.getField('Group10').value == 'FSA') {
    fsabox += claim10.value;
}
if (this.getField('Group11').value == 'FSA') {
    fsabox += claim11.value;
}
event.value = fsabox;


-------------------------

I tried adding the code below, but it doesn't work like I thought it would.

if (fsabox==0)
{
this.textColor = color.white;
}
else
{
this.textColor = color.black;
}

---------------------------

Any idea what's preventing the text color from changing from white to black when the value is not 0?

Thanks in advance!



Replies:
Posted By: Horndoggie
Date Posted: 21 Feb 2014 at 5:41pm
//if total is zero suppress the zero
//place in custom validation
if(event.value==0)event.value="";


-------------
Doug


Posted By: bdavis
Date Posted: 21 Feb 2014 at 5:47pm
Thanks!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 - http://www.webwizforums.com
Copyright ©2001-2017 Web Wiz Ltd. - https://www.webwiz.net