Checkbox Redirects to URL

melvins138 26 Apr, 2017
Hello,

I know this has something to do with EventSwitcher, but I cannot figure it out.

I have a form that has six checkboxes. Depending on which (single) checkbox is selected, the user is directed to a URL when Submit is clicked.

I have searched the forums, but didn't find anything other than switching between CF Pages. (I even asked one of those questions years ago, with much help from Bob)

This seems pretty straight forward, but it is throwing me for a loop.

Thanks in advance for any help.

Melvins138
Max_admin 26 Apr, 2017
Hi Melvins138,

You need to have a PHP code to check the checkbox value and return the event name, then have a redirect action inside that event.

BUT, if you can use v6, then there are much easier possibilities.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 27 Apr, 2017
HI Melvins,

In CFv5 you can probably do it using Custom code. What are the checkbox names and values that you are checking?

Bob
melvins138 27 Apr, 2017
Thanks for the quick responses, Max and Bob.

Max: I installed CFv6, but it's all new, so I'm not sure what I am looking for.

Bob, it's actually radio buttons. I wrote checkboxes, but I meant radio buttons.

** Edited **

I have six radio buttons set up.

Field Name: radio3
Field ID: radio3
Options:
1=I would like to join as a Supporting Member
2=I would like to create a Free Online Account
3=I would like to become a Newsletter Subscriber
4=Upgrade to a Supporting Member
5=Become a Newsletter Subscriber
6=Retrieve your account info

Submit Button

When you click option 1, you go to URL 1 if you choose option 2, you go to URL 2... very simple, right?

I am happy to use either CFv5 or CFv6, whichever you prefer.

Thanks,
Melvins138
GreyHead 27 Apr, 2017
Answer
Hi Melvins,

Here's one way - with a Custom Code action as the last action in the On Submit event:
<?php
switch ( $form->data['xxx'] ) {
  case 1:
  default:
    $url = 'aaa';
    break;
  case 2:
    $url = 'bbb';
    break;
. . .
  case 6:
    $url = 'fff';
    break;
}
$app = \JFactory::getApplication();
$app->redirect($url);
?>

Bob

[[>> later : updated to remove surplus 'default:' lines <<]]
melvins138 27 Apr, 2017
Hi Bob,

Thanks!

I'm curious what the xxx is in $form->data['xxx']. Is that the name of my form?

Thanks again,
Melvins138
melvins138 27 Apr, 2017
1 Likes
Never mind... silly question. I tried placing the form name there, didn't work, but then tried radio3, and it worked.

Thanks again, Bob. You are truly the best... and Max, thank you as well, you guys are awesome!
This topic is locked and no more replies can be posted.