Using Event Switcher to skip pages

EX34Mush 11 Jan, 2017
Having worked out how to create multi-page forms and step through them, I am now trying to work out how to skip a page based on the return from a radio button.
I have found a number of posts relating to this, but so far have been unable to get it to work for me.
I am using a very simple three page form based on the https://www.chronoengine.com/faqs/57-cfv4/cfv4-actions/2658-how-can-i-create-a-multi-page-form.html worked example.

On the first page I have a radio button - skip to page 3 that returns 'Yes' or 'No'

In addition to On Load and Submit I have two other events - page_two and page_three.

I am attempting to use the Event switcher to direct which page to go to when clicking the Next (submit) button.

I have inserted the Event switcher into the On Load Event, and configured it as shown in this image:[attachment=0]Query.jpg[/attachment]

By my understanding, if the radio button radio21 has the value 'Yes' then I should go to the page_three event, otherwise go to page_two.

At present it always goes to page_two regardless of the radio21 setting. Debug confirms the value of radio21 to be as expected.

Any ideas? I feel I am so close to getting this to work, so advice appreciated.

BTW, when someone has a moment, it would be a real help to update the tutorial on multi-pages. There appear to be changes since V4 and it took a lot of detective work to follow the sequence.
EX34Mush 11 Jan, 2017
Should also have mentioned the 'Load Events' button does not appear to achieve anything when clicked.
EX34Mush 22 Jan, 2017
I had hoped someone might have got back to me on this as I hav enot been able to crack it on my own. Anyone out there?
GreyHead 22 Jan, 2017
Hi EX34Mush,

Apologies for failing to reply earlier.

First the Load Events button should update the list of events that you will see in the Action when you look at the setup tab. In this case there should be two separate blocks with the names page_two and page_three. You can't see this until you have saved and closed the action.

You need to add actions to those two events to do whatever you need to happen in that case. In your case probably adding an Event Loop action to each set to the event that you want to loop to. (You could also add HTML (Render form) and the associated Loading actions there directly but using an Event Loop is cleaner.) You will also probably need to add a Multi Page action before the Event Switcher to ensure that the existing data is passed to the next pages.

Bob
EX34Mush 22 Jan, 2017
Hi again Bob,
I think I must be missing something fundamental and not fully understanding what is going on.
I attach two screen-shots. One of the Designer screen, and one of the Setup.
I tried adding Event Loops to each of the event switcher boxes, but got memory problems. I guess it is looping continually until it hits the buffers).

What I have noticed is that when the two Event Switcher boxes are empty I only display page one when I test. With the boxes set up as shown in the screen-shots, pages one and two are shown on the first test screen.

Note that the php code is unchanged from my initial posting.

I am sure once I get my head around exactly what is going on it will be really obvious, but until then... Help!
GreyHead 22 Jan, 2017
Hi EX34Mush,

At least a part of the problem is that there is nothing in the Containers for Pages 2 & 3 on the setup tab. In CFv5 you have to add the elements inside the containers. You can fix this using Copy + Paste + Delete on the Designer tab.

I also see that you have more than one HTML (Render form) action loading the same page - I can't tell if this is a part of your design or not.

The Memory problems were probably because the Event Loop actions were set to load the Event that they were in so you end up going round in circles. They mist be set to load a different event.

Bob
EX34Mush 23 Jan, 2017
Sorry if I am being dense, but I am still not getting this.
You say "At least a part of the problem is that there is nothing in the Containers for Pages 2 & 3 on the setup tab." As I see it I have Multipage and HTML Render in each. Are you referring to some other container that I am overlooking?

Just to clarify what I am trying to achieve:
Page 1 loads and asks if user wants to go to page 2 or page 3;
If they select 'yes', on clicking 'next page' they do directly to page 3. If they select 'no', on clicking 'next page' they go to page 2. Clicking 'next page' on page 2 takes them to page three. Page three submits the form.

My understanding of the ChronoForm process is that
On Load the variables are reset by Multipage and HTML Render displays the form.

Without the Event Switcher, when the user clicks Next Page, the SetUp takes them to 'On page_two'. Multipage retains the previous variables, and displays the page. Similarly for page_three.

I put the Event Switcher in the 'On Load' event because that was where I thought the decision to go to page_two or page_three would be made.

Should it go somewhere else? Perhaps create a new event that does something before page_two or page_three are rendered?

I don't know if others have had similar problems, but a quick video demo on this would be amazingly useful long-term. But if you can help me get this off the ground quickly I would appreciate it.
GreyHead 23 Jan, 2017
Hi EX34Mush,

Are you referring to some other container that I am overlooking?

I'm referring to the Designer tab where you have the page containers.

Bob
EX34Mush 23 Jan, 2017
When I first set this up I used an example of a multipage sequence from the FAQ section. This was written for an earlier version of CF and required the addition of a special Page event. That is not included in CFv5, but experimenting I found that an empty container set to Type=Page seemed to do the trick of moving to a new page. So the empty containers were there simply to start a new page. I have now moved the associated page items into the container to make it tidier. (see screendump).

I have temporarily removed the Event Switcher and checked that the pages and variable values flow correctly.

The next question is where I insert the Event Switcher? Is it in the 'On Load' event box, or elsewhere?
EX34Mush 24 Jan, 2017
1 Likes
Just to let you know that I have now got my head round this and am up and running (at least until the next problem)..As I expected, I had a fundamental misunderstanding of the process. Now I have it, I is all very obvious.

For the benefit of anyone else following this item:

Whilst the Designer section of a multi-page document has to be in sequence, the setup Events do not. So don't worry about adding a new event, so long as it is labelled correctly ChronoForms will find it. The Submit event is a default one, and so far as I can see, you don't have to use it. Just leave it blank if it the label name does not fit your needs.
When using the Event Switcher, it is necessary to create a separate Event for it Control passes from the event that 'houses' the page that sets the variable (radio button in my case), to the event that contains the Switcher, and then from there it will go to whichever event the logic takes it.

Once I appreciated that - and cleared up some typos - it worked. All very logical once understood...
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger