Print Page | Close Window

Javascript popup

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=1575
Printed Date: 21 Sep 2019 at 6:30pm
Software Version: Web Wiz Forums 11.10 - http://www.webwizforums.com


Topic: Javascript popup
Posted By: Maureen
Subject: Javascript popup
Date Posted: 09 Jun 2015 at 12:01pm
Hello,

I'm new with creating fillable pdf forms. Can I get help with a javascript?

I have a field called "kids". The user can fill in number of kids he/she has. When a value is entered in this field, a popup must appears with the text "please fill in the birthday of the children"

thanks in advanced
Maureen



Replies:
Posted By: try67
Date Posted: 09 Jun 2015 at 1:08pm
Use this code as the field's custom validation script:
if (event.value) app.alert("Please fill in the birthday of the children.",3);

-------------
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com


Posted By: Maureen
Date Posted: 09 Jun 2015 at 2:01pm
Thanks for the help. But I just notice that there already is a validation on the field. In the kids field the user can only enter a value between 0-4 kids. Is there another place where I can enter the script you've sended?


Posted By: try67
Date Posted: 09 Jun 2015 at 8:41pm
Yes, as the On Blur event. Just change "event.value" to "event.target.value"


-------------
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com


Posted By: Maureen
Date Posted: 10 Jun 2015 at 1:00pm
I'm sorry but I'm a really "rookie" with Java stuff. What is the Onblur event? Were do I place the script?


Posted By: try67
Date Posted: 12 Jun 2015 at 5:48pm
Under the field's Properties, Actions tab.


-------------
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com


Posted By: Maureen
Date Posted: 29 Jul 2015 at 6:13pm
The code is working, I've placed it on the Calculation tab > custom calculation field of the field where I wanted the popup. But when I enter a value in any other field in the form, the popup appears. What did I do wrong?


Posted By: try67
Date Posted: 29 Jul 2015 at 6:27pm
You didn't follow the instructions I've provided above. This is not a calculation script.


-------------
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com


Posted By: Maureen
Date Posted: 29 Jul 2015 at 8:07pm
I'm sorry. I did it now, but I don't know what trigger to use. I want that the popup appears at the moment the user has filled in a value and click in another field


Posted By: try67
Date Posted: 29 Jul 2015 at 8:39pm
I told you already, use the On Blur event.


-------------
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com


Posted By: Maureen
Date Posted: 30 Jul 2015 at 6:47pm
Oeps Sorry. This also works. Thank you

Can I ask 1 more thing. Hope this is the last one

For example: Field1=100, Field2= 300, In field3 I have a calulation Field1-Field2. I need a script in Field3 that change the text. If Field1>field2 the text color change in blue and if Field1<Field2 the color must be red.

Hope you can help again





Posted By: gkaiseril
Date Posted: 30 Jul 2015 at 8:05pm
I believe there are 3 simple caparisons possible, less then, equal to , and greater than.
 
What should happen if the fields are equal?
 
 


Posted By: try67
Date Posted: 30 Jul 2015 at 8:13pm
You can use this as the custom validation script:

if (event.value>0) event.target.textColor = color.blue;
else if (event.value<0) event.target.textColor = color.red;
else event.target.textColor = color.black;

-------------
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com


Posted By: Maureen
Date Posted: 30 Jul 2015 at 8:30pm
I think didn't explain it right. The color of the text in field3, depends on the outcome of Field1-Field2
In field3 is a formula field1-field2
Example 1  Field1=25, Field2=20. In Field3=5 ; the text color should be blue, because Field1>Field2

Example 2  Field1=20, Field2=25. In Field3=-5 ; the text color should be red, because Field1<Field2

If field1 is equal to field2 then the color is black

Hope this make more sence


Posted By: Maureen
Date Posted: 30 Jul 2015 at 8:32pm
I know that there're 3 caparisons, but how to use it in a script I don't know
If the fields are equal the color is black


Posted By: try67
Date Posted: 30 Jul 2015 at 8:41pm
I did understand... If Field1>Field2 then the result is positive (bigger than zero), no?
And if it's smaller then the result is negative (smaller than zero), etc.


-------------
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com


Posted By: Maureen
Date Posted: 30 Jul 2015 at 9:11pm
You're right. It works again, was bussy doing 2 different things and mix them. Shouldn't do that.

But thanks again. Hope the people for who I'm doing this are pleased with the form


Posted By: gkaiseril
Date Posted: 31 Jul 2015 at 3:08pm
You should explain how you want all the possible outcomes to processed.
You appear to be missing one more possible outcome.



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