Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Display button if >0
  FAQ FAQ  Forum Search   Register Register  Login Login


Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

Display button if >0

 Post Reply Post Reply
Author
BrianG View Drop Down
New Member
New Member


Joined: 17 Jun 2012
Points: 11
Post Options Post Options   Quote BrianG Quote  Post ReplyReply Direct Link To This Post Topic: Display button if >0
    Posted: 20 Apr 2017 at 3:55am
I have a text field that is formatted for numbers.  I also have a button that can be clicked that is set to print a certain page if there is a number in the text field.  If the number in the text field is > 0, I would like the button to become visible (but doesn't print).  If the number in the text field is =<0, I would like the button to be hidden.
 
My text field is named "Atotal".  My button is named "Print A".
 
I tried the following script imbedded in the Print A button, but it doesn't work.  Does anyone have any suggestions?  Thanks.
 
var total = this.getField("Atotal").value;
 var button = this.getField("Print A");
 if (total > 0) {
 button.hidden = false;
 }
 else {
 button.hidden = true;
 }
 
Back to Top
Sponsored Links


Back to Top
BAlheit View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 1095
Post Options Post Options   Quote BAlheit Quote  Post ReplyReply Direct Link To This Post Posted: 20 Apr 2017 at 8:06am
Use something like this:
button.display = display.hidden;

Back to Top
BrianG View Drop Down
New Member
New Member


Joined: 17 Jun 2012
Points: 11
Post Options Post Options   Quote BrianG Quote  Post ReplyReply Direct Link To This Post Posted: 20 Apr 2017 at 9:32pm
It partially works, but I have to click on the text field in order to make the button visible/hidden.  It doesn't happen automatically based on the number in the text field.
Back to Top
BAlheit View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 1095
Post Options Post Options   Quote BAlheit Quote  Post ReplyReply Direct Link To This Post Posted: 21 Apr 2017 at 7:37am
Where did you place the code?
Back to Top
BrianG View Drop Down
New Member
New Member


Joined: 17 Jun 2012
Points: 11
Post Options Post Options   Quote BrianG Quote  Post ReplyReply Direct Link To This Post Posted: 21 Apr 2017 at 1:41pm
In the text field - Atotal
Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4074
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 22 Apr 2017 at 6:02pm
If you put the script in the button, when the button is hidden, not visible, how do expect users to know where to click to activate the button?

I would code that action to the on blur or custom validation JavaScript action. Then the code would only run when the text field is changed and the user exits or loses focus on the field.
Back to Top
BrianG View Drop Down
New Member
New Member


Joined: 17 Jun 2012
Points: 11
Post Options Post Options   Quote BrianG Quote  Post ReplyReply Direct Link To This Post Posted: 22 Apr 2017 at 7:08pm
I have the script in the text field, and it's not working.  I don't need the user to click on the button, just enter a number in the text field and button appears.
Back to Top
Merlin View Drop Down
New Member
New Member
Avatar

Joined: 03 Jun 2012
Location: 43.95 N / 4.82
Points: 38
Post Options Post Options   Quote Merlin Quote  Post ReplyReply Direct Link To This Post Posted: 24 Apr 2017 at 12:54pm
Hi.

Place this JavaScript as a Validation script in the Atotal field:

this.getField("Print A").display = event.value >= 0 ? display.noPrint : display.hidden;


Edited by Merlin - 24 Apr 2017 at 12:56pm
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.016 seconds.