conditional formatting - SIMILAR query

7 views
Skip to first unread message

mimilafl

unread,
Oct 13, 2009, 8:52:06 PM10/13/09
to CenoPDF Support Group
good day, team -- the previous discussion reminded me of something
similar we will want to do in the upcoming weeks.

when requests are made and they need to be worked on within a specific
timeframe {say, two weeks as the example}, we wish to apply
conditional formatting to the pdf request form for those cases where
the request date is LESS than two weeks away from "today."

can you provide examples for:

where today's date = 10/14/2009 -&- request {needed by} date =
10/20/2009

the javascript code example to make a dialog box pop up alerting the
user to enter a date @ least two weeks beyond today's (current) date

-and-

the javascript code example where the request date field changes from
black to say, red/orange/etc. if this date is less than two weeks from
today's (current) date

i s'pose the second one is similar to the previous person's query, but
we are still mulling around whether we want an alert {"PLEASE ENTER A
DUE DATE WITH, @ LEAST, A TWO-WEEK TURNAROUND" - ETC.} or just the
request date to change colors, so both examples would be very
helpful. thx, team. have a good evening-

MLA

CenoPDF Support

unread,
Oct 13, 2009, 11:29:20 PM10/13/09
to cenos...@googlegroups.com
MLA,

I have made an example for you. Please see attached files.
Please be advised that this example only gives you the idea about how it
works. To compare two dates requires more programming to parse the date
format, which beyond our free technical support.

The code in attached example is in On Blur trigger of the text box. Here is
the code:

var input = new Date(event.value);
var today = new Date();

var diffMS = input.getTime() - today.getTime();
var diffDays = diffMS / 1000 / 60 / 60 / 24;

if(Math.abs(diffDays) < 14)
{
app.alert("it has to be two weeks from today.");
event.target.fillColor = ["RGB", 1, 0, 0];
}
else
{
event.target.fillColor = ["RGB", 1, 1, 1];
}

Thanks,

CenoPDF Support
http://www.lystech.com/
compare-date.doc
compare-date.pdf

mimilafl

unread,
Oct 14, 2009, 9:29:47 AM10/14/09
to CenoPDF Support Group
thank you so much for your timely response. pls note -- we were about
to break out the fake champagne when we stumbled upon something else.
LET ME SAY IN ADVANCE, IF YOU ARE NOT ABLE TO ASSIST {i.e., if it is
beyond the scope of a "free" support answer}, IT WILL JUST BE SURFING
THE NET TO--HOPEFULLY--FIND AN ANSWER. so i still appreciate what you
have done thus far...

anyway, i used your code {modified, as you will note below} ALONG WITH
your date difference sample in your online manual. remarkably,
everything WORKED until i accidentally entered "2008" (08) instead of
09 in the field. lo and behold, it still ended up calculating, albeit
GREATER THAN 300 days :o( . after scratching the head, looking over
your code below, and the code in your online manual again, i came up
with the following add'l code. in the real world, the assumption is
someone can, indeed, inadvertently type the wrong year and so forth.
so this was to validate the date before moving on to the next input
field.

******************************

var v1 = this.getField("DueDate").value;
var v2 = this.getField("RequestDate").value;
var v3 = this.getField("curr date").value;
var d1 = new Date(v1);
var d2 = new Date(v2);
var d3 = new Date(v3);
var days = Math.abs(d1.getTime() - d2.getTime()) / 1000 / 60 / 60 /
24;
this.getField("days").value = days;


if(Math.abs(days) < 15)
{
app.alert("Due Date MUST be > 14 days after Request Date {not
accepting rush jobs at this time}. Thx for your cooperation,
everyone!");
event.target.fillColor = ["RGB", 1, 0, 0];
}

else
{
event.target.fillColor = ["RGB", 1, 1, 1];

}


if(d1 < d2) /// TO CENOPDF TEAM -- also tested using "d1 < d3" as
discussed below ///
{
app.alert("Please enter a valid date.");
event.target.fillColor = ["RGB", 1, 0, 0];
}

else
{
event.target.fillColor = ["RGB", 1, 1, 1];

}

******************************

while the above code WORKED, here is the NEW problem/issue we stumbled
upon ==>

when using/testing if(d1 < d2), i INTENTIONALLY entered 05, 00, etc.
for the year and, YES, the alert popped up to enter valid date. of
course, testing for > 14 days also worked. lastly, testing for say,
next year (10), worked {e.g., request date=12/30/09 and due
date=1/22/10, etc.}. BUT, when i entered, say 95 or 99 or even 75 or
other years [BEFORE 2000] just for the heck of it, IT ENDED UP
CALCULATING WITHOUT SHOWING THE ALERT??? it seems as if the y2k (00)
issues are impacting this---perhaps?? is this a correct assumption or
is something else happening here??

anyway, once we saw that, after MUCH thought the next idea came to
mind to just test the due date against the current {today's} date.

so, using/testing if(d1 < d3) resulted in something even more strange,
if you will:

everything tested similar to the above, EXCEPT when pretending it was
the end of the year. the alert to enter valid date popped up when
testing request date=12/30/09 and due date=1/22/10, etc. arbitrarily
entering other dates beyond this year also caused the alert to pop up
{e.g., 2012 and so forth}.

so, the question for this modified version is, what is happening with
2010 and beyond??? are we going to have all sorts of problems next
year, perhaps, because of whatever we stumbled upon here {sort of like
an alternate y2k issue???}.

now--again--if these queries are beyond the scope of your "free"
support, i understand and it will just take awhile, i s'pose, to surf
the net in search of the answers. but, if you can offer any
suggestions {or hints, as you said below "Please be advised that this
example only gives you the idea about how it works."} ;o) , we would
very much appreciate the assistance.

for now, we are also going to modify the code to look @ a combination
of the request date and due date. maybe using both and comparing the
values will force the request form to do exactly as we want...or, just
maybe, we will open a whole new can of worms. we will see-

in closing, thank you so much for your help. this is still a superior
3rd-party software alternative to the huge expense of adobe and we
look forward to years of use with your product. have a very nice day-

MLA



On Oct 13, 11:29 pm, "CenoPDF Support" <supp...@lystech.com> wrote:
> MLA,
>
> I have made an example for you. Please see attached files.
> Please be advised that this example only gives you the idea about how it
> works. To compare two dates requires more programming to parse the date
> format, which beyond our free technical support.
>
> The code in attached example is in On Blur trigger of the text box. Here is
> the code:
>
> var input = new Date(event.value);
> var today = new Date();
>
> var diffMS = input.getTime() - today.getTime();
> var diffDays = diffMS / 1000 / 60 / 60 / 24;
>
> if(Math.abs(diffDays) < 14)
> {
>         app.alert("it has to be two weeks from today.");
>         event.target.fillColor = ["RGB", 1, 0, 0];}
>
> else
> {
>         event.target.fillColor = ["RGB", 1, 1, 1];
>
> }
>
> Thanks,
>
> CenoPDF Supporthttp://www.lystech.com/
>  compare-date.doc
> 54KViewDownload
>
>  compare-date.pdf
> 85KViewDownload

CenoPDF Support

unread,
Oct 14, 2009, 11:36:25 AM10/14/09
to cenos...@googlegroups.com
Trust me. I'd like to help you as much as I can so that we can promote our
product.

The underline problem is these three lines:
var d1 = new Date(v1);
var d2 = new Date(v2);
var d3 = new Date(v3);

v1, v2 and v3 have to be in certain format so that Javascript can
successfully convert them into its internal data d1, d2 and d3; then does
the calculation. To do this, you will need some general experiences of
Javascript programming, which is nothing to do with PDF itself. That is why
I said it was beyond this support.

My test shows that if you use format like "2008/10/11" it works, but if you
use "08/10/11" it does not. To fix it, the way in my mind is to parse the
date yourself by searching slashes "/". Then construct the date by those
date parts.

Thanks,

CenoPDF Support
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.421 / Virus Database: 270.14.15/2434 - Release Date: 10/13/09
19:11:00

mimilafl

unread,
Oct 14, 2009, 3:26:52 PM10/14/09
to CenoPDF Support Group
thx

ok; maybe we will play w/the different format {i can just hear folks
complaining already, since--i would think--most of us are used to
entering dates in m/d/y styles in the u.s.}. oh well.... we will
see. have a good one :o)

On Oct 14, 11:36 am, "CenoPDF Support" <supp...@lystech.com> wrote:
> Trust me. I'd like to help you as much as I can so that we can promote our
> product.
>
> The underline problem is these three lines:
> var d1 = new Date(v1);
> var d2 = new Date(v2);
> var d3 = new Date(v3);
>
> v1, v2 and v3 have to be in certain format so that Javascript can
> successfully convert them into its internal data d1, d2 and d3; then does
> the calculation. To do this, you will need some general experiences of
> Javascript programming, which is nothing to do with PDF itself. That is why
> I said it was beyond this support.
>
> My test shows that if you use format like "2008/10/11" it works, but if you
> use "08/10/11" it does not. To fix it, the way in my mind is to parse the
> date yourself by searching slashes "/". Then construct the date by those
> date parts.
>
> Thanks,
>

mimilafl

unread,
Oct 14, 2009, 8:16:31 PM10/14/09
to CenoPDF Support Group
UPDATE

quick fyi ==> i misunderstood your reply earlier today. thought you
meant the format had to START with year (smile). i realize you
actually meant it would have to be FOUR digits, not two. so retested
using m/d/yyyy format and it WORKED {e.g., 2009 not 09 and so forth}.
also "pretended" to make errors entering the date(s) and everything
worked: the alerts popped up when they should {if the date was in the
past, etc.} and even testing end of year into the next year, the calcs
were correct and no error/alert message if > 14 days.

TOTALLY, TOTALLY thrilled w/this product, team. keep up the great
work.

one final comment: ARE YOU WORKING ON/HAVE ANY PLANS TO ADD
MULTIMEDIA?

i realize acrobat 6.0 to the current version always had that feature
[seems to be underused, though--but if you ever watch MOVIES w/ or w/
out SOUND in a pdf--or even a presenation slideshow, etc.--you know
and appreciate what i am talking about]. whenever i visit someone's
workplace and they have acrobat, it is amazing to see those select few
who have actually embedded a ppt prez {and even, more recently,
youtube.com vids} in a pdf. that pack-&-go feature in ppt does not
always work, but we all know that pdfs are pretty much universal these
days. so it is something to behold to see vids and hear narration or
songs/music & so forth coming from your pdf. pretty sweet.

okay...that was all. take care, folks and THANKS for your superb
assistance. peace-
> > 19:11:00- Hide quoted text -
>
> - Show quoted text -

CenoPDF Support

unread,
Oct 15, 2009, 1:37:40 AM10/15/09
to cenos...@googlegroups.com
Thanks for the update. I am glad it began to work for you. You are right
that adding a movie control is in our plan.

CenoPDF Support
Version: 8.5.421 / Virus Database: 270.14.16/2435 - Release Date: 10/14/09
06:33:00

Reply all
Reply to author
Forward
0 new messages