Redirecting on submit using radio box with mulitple URL's

joybelle 08 Dec, 2011
I'm trying to redirect users to different URL's after pushing submit depending on which option they choose in a radio box. I'm new to using Chronoforms and I'm not sure how do that.
Max_admin 09 Dec, 2011
Hi Joybelle,

Fastest way to do this is using some PHP code, this is needed if your URLs are completely different.

Add a "Custom code" action in the "on submit" event and use this code:


<?php
$mainframe =& JFactory::getApplication();
if($form->data['radio_field_name_here'] == 'x'){
$mainframe->redirect('http://www.chronoengine.com');
}else if($form->data['radio_field_name_here'] == 'y'){
$mainframe->redirect('http://www.chronoengine.com/forums/');
}
?>


Make sure your place the correct field name and links in the code above.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
joybelle 09 Dec, 2011
Thanks Max. I entered the custom code but it redirects me to a blank page. If I have more than 2 radio buttons would the x and y value have to change? I entered the field name and the url within the brackets and parenthesis but I'm not sure where I'm going wrong. Thanks
GreyHead 09 Dec, 2011
Hi joybelle,

Exactly what code have you used? Please copy and paste it here.

Bob
joybelle 09 Dec, 2011
I used this

<?php
$mainframe =& JFactory::getApplication();
if($form->data['input_radio_0'] == 'x'){
$mainframe->redirect('http://kevinhull.org/index.php/events?id=83');
}else if($form->data['input_radio_2'] == 'y'){
$mainframe->redirect('http://kevinhull.org/index.php/events?id=84');
}else if($form->data['input_radio_3'] == 'y'){
$mainframe->redirect('http://kevinhull.org/index.php/events?id=85');
}else if($form->data['input_radio_4'] == 'y'){
$mainframe->redirect('http://kevinhull.org/index.php/events?id=86');
}
?>
GreyHead 10 Dec, 2011
Hi joybelle,

The 'x' and 'y' values depend on the values of the checkboxes in your form. You need to match these up so that the logic works.

If you are getting a blank page with just the template them probably none of the 'if's are being met and you are seeing an empty 'Thank You' page.

Bob
joybelle 10 Dec, 2011
So how would I match these up to make the logic work?
joybelle 10 Dec, 2011
Also do I need to add any other events after the custom code?
montemedia 11 Dec, 2011
Hi all,

I am not a programmer, but thanks to this post, I solved similar issue with select box field.
This is the code:


<?php
$mainframe =& JFactory::getApplication();
if($form->data['searchengine'] == 'Google'){
$mainframe->redirect('http://www.google.com');
}else if($form->data['searchengine'] == 'Yahoo'){
$mainframe->redirect('http://www.yahoo.com');
}else if($form->data['searchengine'] == 'Bing'){
$mainframe->redirect('http://www.bing.com');
}
?>


In my case, select box name and ID is "searchengine" and there are 3 options: Google, Yahoo and Bing.

By the way, thanks for hard work guys. ChronoForms rocks!
joybelle 11 Dec, 2011
Thank you montemedia. The code you put help me figure out that the x and y value was the name of each radio option or checkbox.
This topic is locked and no more replies can be posted.