Expand my Community achievements bar.

SOLVED

Hide multiple pages unless dropdown is selected

Avatar

Former Community Member

Hello,

I have a 4 page form that I need to be able to hide 3 of the 4 pages until a selection is made from a dropdown box on the first page. So, for example, I have pages labeled:

Page 1

Page 2

Page 3

Page 4

I have a dropdown box that has

Page 2

Page 3

Page 4

for options and if no selection is made only Page 1 will be visible. If the selection is Page 2, I would like all pages except page 2 to be hidden and only show page 2, not have 4 pages show and only Page 2's fields show.

Does anyone know how to accomplish this?

Thank you in advance for any insight!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

The only caveat to enabling your requirement is that the first page of the form cannot be removed. If you set page 1 to "hidden" the objects on the page will be hidden but the page itself will remain in the rendered form as a blank page.

The attached demonstrates a form with page 0-4 (5 pages). A drop-down is on page 0 and it controls the rendering of pages 1-4.

Steve

View solution in original post

5 Replies

Avatar

Level 7

It sounds like your best option would be to make pages 2, 3 and 4 hidden from the start and then, based on your dropdown selection (or checkbox selection; checkboxes would probably be easier to work with) you would set the presence to the proper page to "visible". Here's a code sample to help:

if (this.rawValue == "Page 2") {

     form1.page2.presence = "visible";

}

This script is javascript and as such, you'll need to make sure you have javascript selected as your scripting language.

Avatar

Correct answer by
Former Community Member

The only caveat to enabling your requirement is that the first page of the form cannot be removed. If you set page 1 to "hidden" the objects on the page will be hidden but the page itself will remain in the rendered form as a blank page.

The attached demonstrates a form with page 0-4 (5 pages). A drop-down is on page 0 and it controls the rendering of pages 1-4.

Steve

Avatar

Former Community Member

That worked great! Thank you. One other question...do you know how to add the attribute to a button?

Avatar

Former Community Member

The visible/hidden pages. So, for example, if there is a button on the form, clicking it will hide/unhide x page(s).

I also added xfa.host.currentPage = 1; so that it would directly navigate to the page of the selection, but then the selection is deleted from the dropdown, any way to have it go to the page and keep the selection in the dropdown?

Thanks again for the help!

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----