Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Niall, hi
I was trying to follow your advice and coppied this code after the click event and see what happened - simply nothing works, is it possible for you to correct this script. I have no idea about syntax in JAVAscript.
<event activity="click"/>
<event = var choice = app.popUpMenu("Page 1", "Topic 1", "Topic 2", "Topic 3)>
if (choice == "Page 1") {
xfa.host.currentPage = 0;
}
if (choice == "Topic 1") {
xfa.host.currentPage = xfa.host.numPages -7;
}
if (choice == "Topic 2") {
xfa.host.currentPage = xfa.host.numPages -6;
}
if (choice == "Topic 3") {
xfa.host.currentPage = xfa.host.numPages -5;
}>
My doc is about 40 pages and it would be nice to be able to switch between sections quick.
Thank you
Views
Replies
Total Likes
Hi,
It looks like you have inserted the script in the "XML Source" tab. Would not advise that! The XML Source tab is fine for minor amendments / tinkering, but is not the best place to insert script.
When you have LC open in Design view, there is a window at the top called "Script Editor" (available under the Windows menu).
If this is a single line, it is worth dragging the bottom bar down so that you see a few lines of script at a time.
Create a button on the page and then in Script Editor select the click event. You can then insert your text, as below:
The script would be as before, but without the tags (LC inserts these automatically).
var choice = app.popUpMenu("Page 1", "Topic 1", "Topic 2", "Topic 3");
if (choice == "Page 1")
{
xfa.host.currentPage = 0;
}
if (choice == "Topic 1")
{
xfa.host.currentPage = xfa.host.numPages -7;
}
if (choice == "Topic 2")
{
xfa.host.currentPage = xfa.host.numPages -6;
}
if (choice == "Topic 3")
{
xfa.host.currentPage = xfa.host.numPages -5;
}
In the example above I am counting backwards from the total number of pages. If you document is static (number of pages does not increase) you can just script using "xfa.host.currentPage". Just remember that the page numbers are based on a zero numbering system.
Hopefully you should end up with somethin like this:
Good luck,
Niall
Views
Replies
Total Likes
Hooray!!! It works!
Great +1 to you Niall. Do you know if it is possible not to count pages but some how link to object on the required page. Because at the moment my document is static and all text fields restricted to the size of the visible area therefore if I'll make it dinamic page numbers will be changing depending on the end user and how much infor they will put into text field.
How would I refer to the text subform?
Thanks a lot!!!
Views
Replies
Total Likes
Glad you got it working!!
Because your form is static (number of pages does not increase) actually helps you out here.You do not need a flowing form to get this to owrk.
I would advise sticking with "xfa.host.currentPage = xfa.host.numPages"
For example if you wanted an index to go to the last page, the if statement would look like this:
if (choice == "Go to last page")
{
xfa.host.currentPage = xfa.host.numPages; // this is nice clean script that can be copied from one form to another
}
For page 39; xfa.host.currentPage = xfa.host.numPages - 1;
For page 20; xfa.host.currentPage = xfa.host.numPages - 20;
etc...
Test this out, as I think it is the easiest way forward.
If you want to reference a specific object on each page, it can be done but it will make that object active / in focus which may lessen the user experience. The script would look something like this...
if (choice == "Go to last page")
{
xfa.host.setFocus(xfa.form.form1.page40.userInput_textfield); // this will achieve the same thing, but has to be uniquely referenced to objects on each page, ugh
}
Good luck,
Niall
ps I have just tested this. Normally our form is saved as "Dynamic XML form"; but when I saved is as "Static PDF form" the script continued to work. So no problems with static forms.
Views
Replies
Total Likes
Does someone has an example of working pdf using the code below:
<event = var choice = app.popUpMenu("Page 1", "Topic 1", "Topic 2", "Topic 3)>
if (choice == "Page 1") {
xfa.host.currentPage = 0;
}
if (choice == "Topic 1") {
xfa.host.currentPage = xfa.host.numPages -7;
}
if (choice == "Topic 2") {
xfa.host.currentPage = xfa.host.numPages -6;
}
if (choice == "Topic 3") {
xfa.host.currentPage = xfa.host.numPages -5;
}>
Views
Replies
Total Likes
Niall,
Do u have working PDF for the example below:
If you create a button in the master page (or on page 1) and put similar script in the click event:
var choice = app.popUpMenu("Page 1", "Topic 1", "Topic 2", "Topic 3);
if (choice == "Page 1") {
xfa.host.currentPage = 0;
}
if (choice == "Topic 1") {
xfa.host.currentPage = xfa.host.numPages -7;
}
if (choice == "Topic 2") {
xfa.host.currentPage = xfa.host.numPages -6;
}
if (choice == "Topic 3") {
xfa.host.currentPage = xfa.host.numPages -5;
}
When the user click on the button a pop-menu button appears with the heading you have set in the first line of script. We were luck on this form that the dynamic content (adding additional pages) was at the start of the form, so we were able to count backwards from the total number of pages to get out targets right.
Thanks.
Views
Replies
Total Likes
Hi,
Here are some examples:
The first one is for a XFA form with a static number of pages (eg easier to keep track of sections): https://acrobat.com/#d=f0knWwFdm45r80NeuqtUvw
This second example is a dynamic XFA form as the user can add pages. https://acrobat.com/#d=0Vwv8jvHYfBuQuGjmjCGrA
In both cases check out the script in the click event of the index button. The buttons is on the Master Page, but does not appear in LC Designer as the way we were working image buttons at the time.
I hope these help,
Niall
Views
Replies
Total Likes
Views
Like
Replies
Views
Likes
Replies