Skip to content

Conditional Branching

In Aliveforms, depending upon answers of visitors, different questions/screens can be shown.

How to change flow of questions

In Aliveforms, there are different ways to change question flow.

  • Using form editor
  • Using logic units
  • using actions
  • using JavaScript API.

Example of changing flow of questions

Here is example of form that requires changing flow of questions.

Screen Type Title Extra
0 Text Input Enter your name
1 Options Do you have account Yes/No
2 Rating Rate our services Submit Screen
3 Submit Thank you Submit Screen

Now, here what we require is to if visitors reply yes, then show rating screen, else show submit screen.

Changing next question flow from form.

On screen 1, since the multiple selection is off, this method will work. On option 1, if option settings are not visible, click on setting icon to expand settings and from next screen drop down, select screen 3.

Set Previous Screen

We require if visitor goes to screen 3, then if going back to previous screen is allowed, we required visitor to have screen 1 displayed. for this, check allow going back to previous screen and from drop down, select screen 1.

Changing next question flow from logic

It can be done via actions or JavaScript api.

Changing flow using actions

For this add and apply new client logic unit. and setup following

input: input of screen
screen number : 1
operation: equals
values to match: 1
actions:
name: Change Flow
value: 3

Changing flow using JavaScript API

For this, have logic unit applied on screen 1 and use following snippet

if (input == 1) {
$.ChangeFlow(3)
// // or 
// $.ChangeFlow(screen + 2)
}

How to show different previous Screen

When changing forward flow, form may require change in previous screen flow. For this in screens there is setting for previous screen when allow going back to previous screen is checked. User can use drop down and select which screen to show when back button is pressed.

How to change previous screen flow with JavaScript API.

Previous screen flow can be changed via JavaScript API too. For example, on screen visitors select No, then on screen 3, it is required user to go back to screen 1.

// suppose options are 0: yes 1: no
if (screen == 1) {
    if (input == 1) {
        $.ChangePrevious(3, 1);
    }
}