How to simulate Radio Buttons on PDF forms: Difference between revisions

From Scribus Wiki
Jump to navigation Jump to search
Line 14: Line 14:
   
   


On your form, create two or more Check Boxes and use a Text Frame to label each with suitable text. Each Check Box should also have a suitable name to reflect the answer. In this example we will have three Check Boxes called “Yes”, “No”, “Maybe” and three Text Frames containing “Yes”, “No”, “Maybe”. Take care when naming and using JavaScript as Acrobat is case sensitive.
On your form, create two or more Check Boxes and use a Text Frame to label each with suitable text.  
 
Each Check Box should also have a suitable name to reflect the answer.  
 
In this example we will have three Check Boxes called '''“Yes”, “No”, “Maybe”''' and three Text Frames containing '''“Yes”, “No”, “Maybe”.'''
 
Take care when naming and using JavaScript as Acrobat is case sensitive.
 
You should end up with something like this on your page.
You should end up with something like this on your page.
   
   
Right click with your mouse on the “Yes” Check Box (Blue Square)
Right click with your mouse on the '''“Yes” Check Box''' (Blue Square)
A menu pops up and select PDF Options –> Field Properties
 
Next select the Action Tab –> choose JavaScript and then in the default Mouse Up event -
A menu pops up and select '''PDF Options''' –> '''Field Properties'''
 
Next select the '''Action Tab''' –> choose '''JavaScript''' and then use the default '''Mouse Up''' event -
 
Click on Edit and insert the following
Click on Edit and insert the following


Line 28: Line 38:
this.getField("Maybe").value = "Off"
this.getField("Maybe").value = "Off"


'''Note''' the  // means the first line is commented out.
'''Note''' the  '''//''' means the first line is commented out.


This makes it easy to Copy and Paste the code to all the Check Boxes.
This makes it easy to Copy and Paste the complete code to all the Check Boxes.


Click on '''Save''' and '''Exit'''.  
Click on '''Save''' and '''Exit'''.  
Line 38: Line 48:
   
   


In the “No” Check Box, repeat the process with
In the '''“No” Check Box''', repeat the process with


this.getField("Yes").value = "Off"
this.getField("Yes").value = "Off"
Line 47: Line 57:




and then with the “Maybe” Check Box
and then with the '''“Maybe” Check Box'''


this.getField("Yes").value = "Off"  
this.getField("Yes").value = "Off"  
Line 55: Line 65:
//this.getField("Maybe").value = "Off"
//this.getField("Maybe").value = "Off"


Now save your document as a PDF and view in Adobe Acrobat Reader.  
Now save your document as a PDF and view the PDF file using Adobe Acrobat Reader.  


You should have the following.
You should have the following which functions like Radio Buttons.

Revision as of 04:19, 30 May 2007

Introduction

(From Wikipedia, the free encyclopedia) A radio button or option button (sometimes improperly referenced as "radial button") is a type of graphical user interface widget that allows the user to choose one of a predefined set of options. Radio buttons are arranged in groups of two or more and displayed on screen as, for example, a list of circular holes that can contain white space (for unselected) or a dot (for selected). Adjacent to each radio button is normally shown a caption describing the choice that this radio button represents. When the user selects a radio button, any previously selected radio button in the same group becomes deselected. Selecting a radio button is done by clicking the mouse on the button, or the caption, or by using a keyboard shortcut.

Currently Scribus is unable to create radio buttons on pdf forms as the Adobe technique for creating Radio Button Objects is for a group to all have the same name. Scribus does not allow objects to have the same name.

Fortunately, a group of Check Boxes containing a little java script in each can be used to simulate a group of Radio Buttons.

The method by example

Select the “Check Box” from the pdf fields on the tool bar.


On your form, create two or more Check Boxes and use a Text Frame to label each with suitable text.

Each Check Box should also have a suitable name to reflect the answer.

In this example we will have three Check Boxes called “Yes”, “No”, “Maybe” and three Text Frames containing “Yes”, “No”, “Maybe”.

Take care when naming and using JavaScript as Acrobat is case sensitive.

You should end up with something like this on your page.

Right click with your mouse on the “Yes” Check Box (Blue Square)

A menu pops up and select PDF Options –> Field Properties

Next select the Action Tab –> choose JavaScript and then use the default Mouse Up event -

Click on Edit and insert the following

//this.getField("Yes").value = "Off"

this.getField("No").value = "Off"

this.getField("Maybe").value = "Off"

Note the // means the first line is commented out.

This makes it easy to Copy and Paste the complete code to all the Check Boxes.

Click on Save and Exit.

You should have the following displayed.


In the “No” Check Box, repeat the process with

this.getField("Yes").value = "Off"

//this.getField("No").value = "Off"

this.getField("Maybe").value = "Off"


and then with the “Maybe” Check Box

this.getField("Yes").value = "Off"

this.getField("No").value = "Off"

//this.getField("Maybe").value = "Off"

Now save your document as a PDF and view the PDF file using Adobe Acrobat Reader.

You should have the following which functions like Radio Buttons.