These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

pop-up menu links

crash0430
Registered: Jan 24 2008
Posts: 18
Answered

I have a pop-up menu that links to page numbers, but I am trying to make it link to page views so when I change one of the pages at a future date I dont have to go back in and change every single mage number. My unifinished code is as follow:

var cItem = app.popUpMenu("Index", "-", "Chapter 1","Chapter 2",
"Chapter 3","Chapter 4","Chapter 5","Chapter 6");

switch (cItem) {
case "Index" :
this.pageNum = 0; // set page number for zero based page
break;

case "Chapter 1":
this.pageNum = 1; // set page number for zero based page
break;

case "Chapter 2":
this.pageNum = 2;
break;
}

any suggestions? I am using adobe 8 professional.

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You could add a named destination to each chapter's first page and then use the "this.gotoNamedDest(cName)" method.

George Kaiser

crash0430
Registered: Jan 24 2008
Posts: 18
how do you set a apage as a named destination?
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
One place to start is Acrobat's complete help.

Choose your Destination, http://www.acrobatusers.com/tutorials/2007/choose_your_destination/

Forming named destinations from Word to pdf, http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=4313

George Kaiser

crash0430
Registered: Jan 24 2008
Posts: 18
I have named all of the destinations, but it still doesnt seem to work, unless I am doing it wrong. here is what I have for the first example:

var cItem = app.popUpMenu("Index", "-", "Chapter 1","Chapter 2",
"Chapter 3","Chapter 4","Chapter 5","Chapter 6");

switch (cItem) {
case "Index" :
this.pageNum = 0; // set page number for zero based page
break;

case "Chapter 1":
this.gotoNamedDest = (cChap01); // set page number for zero based page
break;

Of course the first named destination is Chap01 for chapter 1. when I click on Chapter 1 in the popup menu, nothing happens.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
If the name of the destination is "Chap01" you can either set a variable to the string value:

cChapNo = "Chap01"; // set variable with the destination name
this.gotoNamedDest = (cChapNo); // this code could be placed within the case or after switch if all actions can be set with a value to cChpaNo

or just put the string in JavaScript method:

this.gotoNamedDest = ("Chap01);

George Kaiser

crash0430
Registered: Jan 24 2008
Posts: 18
I have tried it both ways in various forms and it still doesnt seem to work. I click on the Chapter 01 and nothing happens. Any thoughts?

var cItem = app.popUpMenu("Index", "-", "Chapter 01","Chapter 02",
"Chapter 03","Chapter 04","Chapter 05","Chapter 06");

switch (cItem) {
case "Index" :
this.pageNum = 0; // set page number for zero based page

case "Chapter 01":
cChapNo = "Chap01"; // set variable with the destination name
this.gotoNamedDest = (cChapNo); // this code could be placed within the case or after switch if all actions can be set with a value to cChpaNo
break;

case "Chapter 02":
cChapNo = "Chap02"; // set variable with the destination name
this.gotoNamedDest = (cChapNo); // this code could be placed within the case or after switch if all actions can be set with a value to cChpaNo
break;

}

I have also tried with the other:

var cItem = app.popUpMenu("Index", "-", "Chapter 01","Chapter 02",
"Chapter 03","Chapter 04","Chapter 05","Chapter 06");

switch (cItem) {
case "Index" :
this.pageNum = 0; // set page number for zero based page

case "Chapter 01":
this.gotoNamedDest = ("Chap01");
break;

case "Chapter 02":
this.gotoNamedDest = ("Chap02");
break;
}

which did not work either
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
The "gotoNamedDest()" is a method with a passed parameter and not a value that is set. Going to a page number is setting a value.

var cItem = app.popUpMenu("Index", "-", "Chapter 01","Chapter 02",
"Chapter 03","Chapter 04","Chapter 05","Chapter 06");

switch (cItem) {
case "Index" :
this.pageNum = 0; // set page number for zero based page

case "Chapter 01":
this.gotoNamedDest("Chap01");
break;

case "Chapter 02":
this.gotoNamedDest("Chap02");
break;
}

You should get a copy of the Acrobat JavaScript documentation and look at, it will help you understand how each property and method work and what objects are available.

George Kaiser

crash0430
Registered: Jan 24 2008
Posts: 18
thank you, this worked great
crash0430
Registered: Jan 24 2008
Posts: 18
Do you know if there is an easy way to add this to every page without just copy and pasting it?
crash0430
Registered: Jan 24 2008
Posts: 18
acutally, I am now making a heierarchal list and was wondering how to make the links for the second part. This is what I am starting with:

var aChap04 = ["Chapter 04","Spreadsheets/Tables","Details/Sketches","Discussions/Articles","Calculations","Reference/Resource","Codes"]

switch (aChap04) {
case "Spreadsheets/Tables":
this.gotoNamedDest("Spread4");
break;

case "Details/Sketches":
this.gotoNamedDest("Det4");
break;
}

with the rest of the code following.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Have you studied the example the Acrobat JS API Reference?

http://www.adobe.com/devnet/acrobat/javascript.php

George Kaiser