hub.eb?material_id=197&track_id=350

Call Form


The Verj.io JavaScript API's form interface includes a form.callForm("mySecondForm") function that suspends the current event's execution and navigates to the specified Form. The original Form's state is not lost however.

The original Form can be returned to using the form interface's returnFromForm() function that navigates back to the original Form and resumes the suspended event's execution.

The returnFromForm() function will display an error if used on a Form that has not been navigated to using the callForm() function. You can avoid this by checking if the Form was called:

if(form.calledForm){
  form.returnFromForm();
}

Steps


1

Create two Forms and name them one and two.

2

Add a Button Control to the Form one's Page with the text: Call Form Two.

Create a Script containing the following code and add it to the Button Control's On Click Event:

form.callForm("two")

// script resumes here on return
if(controls.myButton.backgroundColor == "green"){
  controls.myButton.backgroundColor = "purple";
}
else{
  controls.myButton.backgroundColor = "green"
}
3

Add a Field called myField to Form one and drag it on to its Page as a Field Control.

4

Add a Button Control to the Form two's Page with the text: Return to Form One.

Create a Script containing the following code and add it to the Button Control's On Click Event:

if(form.calledForm){
  form.returnFromForm();
}
5

Run  Form one and add a value to the Field.

Click the Call Form Two button.

Click the Return to Form One button.

Note that, on returning to first form the Field value is unchanged,  the button's event continues and changes its colour.

Current Module

Related