• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

I want Radio Button choices to cause a go-to-page action

New Here ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

Let’s say I have three sets of variables:

Large, Medium, Small. 

Red, White, Blue.

Cat, Dog, Fish.

I want to assign a set of radio buttons to each row. The user would make one choice within each row and, depending on what the three choices were, would jump to a specific page in the document. So, if they choose Small Red Dog they’re sent to page 22, if they choose Medium Blue Fish they’re sent to page 16, etc.

But now I don’t know how to proceed. How do I tell Acrobat to jump to a specific page based on specific radio button choices?

TOPICS
How to , JavaScript , PDF forms

Views

3.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

You may be able to achieve this by doing the following:

 

  • Open the "Prepare Form" tool --When you open it you will be able to access different PDF editing tools and features.

 

  • Hover the mouse pointer over the desired radio button and Right-click on it --> Select from the context menu "Properties" and left-click with your mouse once on that selection ("Properties" is the first hoice if you read the context menu from top to bottom)

 

  • The "Radio Button Properties" dialogue window will open up next --- click on the "Actions" tab

 

  • Look at the section that is labeled "Add an Action" --->> "Select Trigger:" --->>> choose from the dropdown menu next to it "Mouse Up" 

 

  • Then in the section right below it "Select Action:" select from dropdown menu "Go to a page view" --->>> then click the "Add..." button

 

  • As soon as you click on "Add..." a pop up menu will open;  click on the "Set Link" button

 

  • You'll be returned to the Radio Button Properties window dialogue where you'll see the Mouse Up action added to this radio button

 

  • See where it says "Go to a page in this document" --->>> to change the page number, click once on it once to select and then click on the "Edit" button below

 

  • A new dialogue window will open up: "Go to a page in this document"

 

  • Type in the desired page in the blank provided, then clickthe OK button --->>> you'll be returned to the Radio Button Properties dialogue window --->>> Click the "Close" button to exit 

 

  • Close the Prepare Form tool

 

  • And save your document

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

This won't work for what they described. You would have to use a script with conditional logic to check the state of all three radio-button groups so you could decide which page to go to. If you use the "Go to a page view" command it's hard-coded and can't be made conditional on other factors.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

You're right, I missed the conditional part completely which depends on thre choices made.

 

This brings me to another question: How many sets of  radio buttons are assigned to each row?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

This is a bit tricky to implement, and as I wrote above, it will require using a script.

The way I would do it is by using a (hidden) text field to concatenate all the values from the radio-buttons and then decide which page to go to (if at all) based on that string. In order to do that you can use the following code as that field's custom Calculation script:

 

event.value = this.getField("Group1").valueAsString + " " + this.getField("Group2").valueAsString + " " + this.getField("Group3").valueAsString;
if (event.source && (event.source.name=="Group1" || event.source.name=="Group2" || event.source.name=="Group3")) {
	if (event.value=="Small Red Dog") this.pageNum = 21; // Go to page 22
	else if (event.value=="Medium Blue Fish") this.pageNum = 15; // Go to page 16
	// etc.
}

 

You will need to adjust the field names in the first two lines so that they match the actual names in your file, since you didn't specify them in your question.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

Thank you all for taking the time to respond. I know very little about JS so while I take the time to parse out your recommendations, I want to mention that a direction that occurred to me was to assign a different numerical value to each radio button so that the sum of any possible combinaiton would result in a unique number. E.g, 

100 to Large, 200 to Medium, 300 to Small,

10 to Red, 20 to White, 30 to Blue,

1 to Cat, 2 to Dog, and 3 to Fish. 

(Medium Blue Fish would be 233, Small Red Dog would be 312, etc.). 

So I would tell Javascript- If the sum = 233, jump to page 16, etc. I just don't  know how to program that "jump here if you see this number" function. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

@try67: I copied and pasted your code into the JS field in the Prepare Forms tool and got a Syntax Error (Missing ;). I've uploaded a rough  PDF with the three groups of radio buttons installed. If you have time could you try to implement your solution in that doc?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

Did you edit it in any way, because there's no such error in the code I posted.
I also don't see where's the text field you were supposed to add and place the code under...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

Here you go, it's working fine for me (select the first three options and it jumps to page 21).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

That works beautifully. Thank you. I must have copied it wrong. Can you confirm that subsequent lines would look like this:

 

if (event.value==”Small Red Dog”) this.pageNum = 21; // Go to page 22

else if (event.value==”Medium Blue Fish”) this.pageNum = 15; // Go to page 16

else if (event.value==”Medium Red Fish”) this.pageNum = 16; // Go to page 17

else if (event.value==”Medium Green Fish”) this.pageNum = 17; // Go to page 18

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

Correct. But you don't need to add the comments, of course...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

Now I must expose how little I know javascript: Which parts are comments?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

The text after // .

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

Also, I noticed you used curly quotes (    ) in the code you posted above. That won't work.

You must only use straight-quotes ( " " ). Do NOT use Word to edit the code, if that's what you're doing. Only use a plain-text editor. I recommend Notepad++.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

Yeah, the quote marks were defaulting to "typographers quote marks" which I fixed, thanks.

One more issue: When I open the file in Reader, the buttons which are part of a group have the blue field highlight fill. They don't have that in Acrobat. And the buttons which are not part of a group do not have the blue in Reader. I have "Highlight existing fields" and "Show border hover color for fields" both unchecked. Any ideas?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

This is a setting of each application, not of the file, although you can embed a script in your file to turn this setting on or off.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

I see. Will I be wearing out my welcome to ask you what that script would look like?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

No, but I should warn you that if you do embed this code in your file it will disable the Fields Highlighting for all the files the user opens after viewing it, so it might be a good idea to warn them about it, or get the approval for making this change to their application. Do you want to enable or to disable it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

Actually, nevermind. I'll just advise the users to manually hide the field color.

 

Thanks again for all your help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

That's a good idea. You can do that with a script, too, though.

Something like this (as a doc-level script):

 

if (app.runtimeHighlight) app.alert("It's recommended to turn off fields highlighting to view this file correctly.",3);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

That's a great idea. BTW, what does  the comma-3 do in this line?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

It determines what icon will be used in the alert window. 3 stands for the "Information" icon (a "i" inside a blue circle).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

Time for me to study JS. Any recommendations where to start?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

Note that this is Acrobat JS, and most tutorials online are for web-based JS. While the two share a common syntax, almost everything else is different.

Here are some good resources to get you started:

General JS tutorial: http://www.w3schools.com/js/default.asp
Homepage of the Acrobat SDK, including a link to the full API: http://www.adobe.com/devnet/acrobat.html
Free tutorials about Acrobat in general, including many JS related ones: https://acrobatusers.com/tutorials/
A paid-for website with tutorials about Acrobat JavaScript (not related to me): http://www.pdfscripting.com/
My own humble web-site with many tools for Acrobat and Reader (mostly paid-for, some free): http://www.try67.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

Perfect. 

 

Until next time...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines