Skip to main content
Participant
March 24, 2020
Question

Setting up actions for a button

  • March 24, 2020
  • 3 replies
  • 1531 views

I am using Adobe Acrobat Pro for a pdf school schedule.  I would like to add a button to each class space on the schedule that when clicked opens a form field showing the class description.  I would like a mouse click to open the form field, then click to close it.  When I set this up the form field appears, but will not stay open unless I drag the mouse down to the field. What am I missing?

This topic has been closed for replies.

3 replies

ls_rbls
Community Expert
Community Expert
April 7, 2020

Hi,

 

Just checking if you were able to resolve this issue. Let me know if my help was useful and don't forget to mark the answer as correct if the code worked for you.

Bernd Alheit
Community Expert
Community Expert
March 25, 2020

You can use the "Mouse Enter" and "Mouse Exit" events.

ls_rbls
Community Expert
Community Expert
March 25, 2020

Hi,

 

This is a lot easier done using a checkbox instead of a button with mouse functions.

 

You can create a check box next to the class space text field.

 

Right-click on the checkbox, select Properties from the context menu, and click on the Actions tab.

 

Add an action MouseUp event, and select action "Run  a JavaScript". Click Add, then Edit, and insert this line of code(or similar):

 

 

// set your variables
var a = this.getField("your Check Box fieldname here").value;
var b = getField("name of text field that contains the class space info");

//establish a condition based on the checked or unchecked state of the checkbox
// if the checkbox is checked the text field will be visible

if (a == "Yes") event.value = b.display = display.visible;


// when the checbox is unchecked the field is not visible or hidden

else if (a == "Off") event.value = b.display = display.hidden;

 

 

Participant
March 25, 2020
Thank you so much for your help.  I'm afraid Javascript is way over my head.  If I am reading your response correctly, this is what the Javascript should be for a "SpanishCheckBox" and "SpanishField".  I keep getting Syntex errors.  Could you please explain?

var a = this.getField"SpanishCheckBox".value; var b = getField("SpanishField");(a == "Yes") event.value = b.display = display.visible;(a == "Off") event.value = b.display = display.hidden;
ls_rbls
Community Expert
Community Expert
March 26, 2020

Ok you almost got it.

 

Here is the script with the proper syntax:

 

var a = this.getField("SpanishCheckBox").value; 
var b = getField("SpanishField");

if (a == "Yes") event.value = b.display = display.visible;
else if(a == "Off") event.value = b.display = display.hidden;