Implement External Form Navigation

Edit in →

SurveyJS ships with multiple navigation features that you can add to your forms: navigation buttons, a table of contents, and various types of progress indicators. You can also implement custom navigation elements that extend the built-in functionality or completely replace it. This demo shows how to implement external form navigation controls—a page selector, navigation buttons, and a progress indicator—and use them in conjunction with built-in form navigation features.

Configure a Page Selector

A page selector is a UI element that displays a list of survey pages and enables users to jump to a selected page. Usually, a page selector is a drop-down menu. If your survey contains a few pages only, a page selector can be a set of buttons with page numbers.

This example demonstrates a drop-down page selector built upon a standard <select> HTML element. To fill <select> options, iterate over SurveyModel's visiblePages array and create an <option> element for each array item. Within the <select> element's onchange event handler, call the current page's validate() method to perform validation. If all answers on the current page are valid, assign the selected page number to SurveyModel's currentPageNo property. Note that this property starts to enumerate survey pages with 0.

Implement Navigation Buttons

Built-in survey navigation buttons include Start, Next Page, Previous Page, Preview, and Complete. Depending on your use case, you may need to implement all the buttons or only a part of them. This demo implements the Next Page, Previous Page, and Complete buttons.

Add <button> elements to your page. To navigate between survey pages, call SurveyModel's nextPage() and prevPage() methods within <button>'s onclick event handler. To end the survey, call the completeLastPage() method.

Navigation button visibility may depend on the current page. For example, the Previous Page button should not be visible on the first survey page, or the Complete button should appear only when a user has reached the last page. To control button visibility, use SurveyModel's isFirstPage and isLastPage properties or compare the currentPageNo property value with the length of the visiblePages array.

If you implement custom navigation buttons, you may want to hide the built-in buttons to avoid functionality duplication. To do this, disable the showNavigationButtons property. This demo, however, keeps the built-in buttons visible to show how they can work alongside custom buttons.

Add a Progress Indicator

A progress indicator helps users understand how far along the survey they have advanced. Progress indicators can show the number of completed survey pages, answered questions, or other progress information. In this demo, a progress indicator displays the current page number and the total number of survey pages. Use SurveyModel's currentPageNo property and the length of the visiblePages array to implement this progress indicator. Note that currentPageNo starts to enumerate survey pages with 0. Therefore, you need to add 1 to its value to get the actual current page number.

Handle Navigation Events

A survey raises the following events that may be useful when you implement an external navigation system:

Your cookie settings

We use cookies on our site to make your browsing experience more convenient and personal. In some cases, they are essential to making the site work properly. By clicking "Accept All", you consent to the use of all cookies in accordance with our Terms of Use & Privacy Statement. However, you may visit "Cookie settings" to provide a controlled consent.

Your renewal subscription expires soon.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.

Your renewal subscription has expired.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.