Forums

How do I load a different form after I submit the current form

gilgal_media 27 Dec, 2014
I have a drop down of 3 items and each item has a different form. After selecting and submitting "item 1" it is supposed to load "form 1". I would like to know how I should do it.
Max_admin 27 Dec, 2014
1 Likes
You can use an "Event switcher" action and setup 3 events for the 3 options and use 3 redirect actions, each to a different form.

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
gilgal_media 27 Dec, 2014
I used the Event switcher action, setup 3 events for the 3 options and redirect actions but it redirects to the 1st form for all the 3.

My drop down ID is "liketodo". The options are 0=View a Bible, 1=Reserve a Bible, 2=Purchase a Bible. Each one has a different form i.e ("view-bible", "reserve-a-bible", purchase-a-bible") respectively but they all load "view-bible" form after submitting.

Below is the code for the Event Switcher I am using; please check whether this is correct;

<?php
if($form->data['liketodo'] == 0){
return "view-bible";
}
if($form->data['liketodo'] == 1){
return "reserve-a-bible";
}
if($form->data['liketodo'] == 2){
return "purchase-a-bible";
}
?>
gilgal_media 28 Dec, 2014
[attachment=0]Firefox_Screenshot_2014-12-28T12-53-36.449Z.png[/attachment]
gilgal_media 28 Dec, 2014
[attachment=0]Firefox_Screenshot_2014-12-28T12-57-26.453Z.png[/attachment]
Max_admin 30 Dec, 2014
The first image doesn't have an "event switcher" action, you have a "Custom code", that's wrong, the Event switcher action will have 3 events where you should place your 3 redirect actions so that the switching can be done based on the value.

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
gilgal_media 30 Dec, 2014
Thanks Max,

I have setup "Event Switcher" action with 3 events and 3 redirect actions. After submit it does not load the respective form. Am not so good with coding, I hope to help me in this please.

Attached are images;
[attachment=0]Firefox_Screenshot_2014-12-30T21-10-14.766Z.png[/attachment]
[attachment=1]Firefox_Screenshot_2014-12-30T21-12-04.099Z.png[/attachment]

The event switcher code i put in is;
<?php
if($form->data['liketodo'] == 0){
return "view-bible";
}
?>

<?php
if($form->data['liketodo'] == 1){
return "reserve-a-bible";
}
?>

<?php
if($form->data['liketodo'] == 2){
return "purchase-a-bible";
}
?>
GreyHead 31 Dec, 2014
Hi gilgal_media,

There can be problems using 0 and 1 as option values*. I'd suggest that you change those to more meaningful values:
view-bible=View a Bible
reserve-a-bible=Reserve a Bible,
purchase-a-bible=Purchase a Bible

Then the event switcher can just use:
<?php
// set a default value if liketodo is missing or empty
if ( !isset($form->data['liketodo']) || !$form->data['liketodo'] ) {
  $form->data['liketodo'] = 'view-bible';
}
return $form->data['view-liketodo'];
?>

Bob
gilgal_media 31 Dec, 2014
Thank you Bob for your assistance, however after changing everything & submit I receive this error;
=============
Parse error: syntax error, unexpected T_BOOLEAN_OR, expecting ',' or ')' in /home/gilgalme/public_html/view.gilgalmediaarts.com/wp/wp-content/plugins/chronoforms/admin/chronoforms/actions/event_switcher/event_switcher.php(26) : eval()'d code on line 3
=============
Here are the images;
GreyHead 01 Jan, 2015
Hi gilgal_media.

Sorry, I missed a ) in this line:
if ( !isset($form->data['liketodo']) || !$form->data['liketodo'] ) {

:-(

Bob
gilgal_media 01 Jan, 2015
Thanks so much Bob,

The code works and does not return the error anymore now. However the intended form is not displayed. I think problem is in the "redirect" action.
It is supposed to redirect to a form "view-bible". Please help me with the "redirect" action code. Below image is what i used.
GreyHead 02 Jan, 2015
Hi gilgal_media,

please remove the entry in the Extra Params box - it isn't doing anything useful here. See if that works. If not, what is the URL that you are being redirected to?

Bob
This topic is locked and no more replies can be posted.