Question T3413
Visible to All Users

Is it possible to handle 'next' button manually?

created 5 years ago

It's a simple requirement , I have a survey with 2 pages , and I want to query back-end server when I click 'Next' button in the survey , if server return a true , then jump to next page , if false , stay in current page and do something else.

so what I need are:

  1. to handle the event of 'Next' button myself.
  2. trigger next or previous event manually.

and I have another problem , if I have 2 input element in survey , and I want to show validation message if the amount of these two input more than 100.

is there a way to do these 2 requirements?

Answers approved by surveyjs Support

created 5 years ago

Hello,

In order to implement custom navigation algorithm you need to write something similar https://github.com/surveyjs/survey-library/blob/master/src/survey.ts#L2778-L2790 code in your custom "next" processing function. You can debug this code and decide how to implement exactly your scenario.

Thanks, Serge
SurveyJS Team

    created 5 years ago

    Hello,

    Yes. You can implement custom navigation as shown in this live sample - https://www.surveyjs.io/Examples/Library?id=survey-customnavigation&platform=jQuery&theme=modern

    Thanks, Serge
    SurveyJS Team

      Comments (2)

        Hi Serge , thanks for your answer , I'm not sure I was totally understand that demo. did you mean I can get the instance of next button by

        Code
        document.getElementById('surveyNext');

        and override onclick method. right?

        but in my demo , document.getElementById('surveyNext') always return a null . can you take a look at it?
        https://stackblitz.com/edit/react-surveyjs-29dj

          @Serge Hi, Serge . Now I can override the Next button to my custom function. but it still trigger the next page function, I want prevent the default 'next' function. can you take a loot at that demo?