Forums

Can chronoform redirect to the predefined link

Ron 15 Mar, 2011
Hello,

I have been using chronoforms for quite sometime now. I must say they work flawlessly. Thanks the chronoforms team.
I have an issue for which I am unable to find a solution. I want a drop down menu in my chronoform. (Say countries) when chosen directs to a particular link.

For example when I choose "Russia" in the drop down list I should immediately be directed to the particular chronoform that is suitable for that country.

Would someone help as to how I could achieve that ?

Thanks for any possible help.
WBW

Ron
Ron 29 Mar, 2011
Thanks Bob for the help.

Yes the post was helpful. But what I need is as-soon-as the choice is made the form should redirect to the desired location. No need to press submit.

On onsubmit I have a bit of problem as the form redirects to only one url. which I feel is not as per the code below.


<?php
$option = JRequest::getString('option');
switch ($option) {
  case 'Asia':
  default:
    $url = 'option=com_chronocontact&chronoformname=usd_price_iecp';
    break;
  case 'Africa':
    $url = 'option=com_chronocontact&chronoformname=usd_price_iecp';
    break;
  case 'North America':
    $url = 'option=com_chronocontact&chronoformname=usd_price_iecp';
    break;
  case 'South America':
    $url = 'option=com_chronocontact&chronoformname=usd_price_iecp';
    break;
     case 'Australia':
    $url = 'option=com_chronocontact&chronoformname=usd_price_iecp';
    break;
     case 'Europe':
    $url = 'option=com_chronocontact&chronoformname=sl200_euro';
    break;
     case 'Antarctica':
    $url = 'option=com_chronocontact&chronoformname=usd_price_iecp';
    break;
}
$url = 'index.php?'.$url;
$mainframe->redirect($url);?>
?>


Please help.

Thanks

Ron
GreyHead 29 Mar, 2011
Hi Ronn,

To get an instant redirect then you'll need to use JavaScript to add a submit action to the select box. Be careful with this as you may find people are mis-selectign and being redirected to placed that they don't want to go.

The code you posted looks fine, if everything is going to one URL then probably 'option' doesn't have the values that you are expecting.

Bob
nml375 29 Mar, 2011
Hi Ron & Bob,
Just to drop in here. It's a bad idea to use the name "option" for any of your entries, as this is used by Joomla to decide which component may handle the request (in this case, Chronoforms; thus the value would always be 'com_chronocontact' when your chronoform parses that piece of html).

/Fredrik
Ron 30 Mar, 2011
Thanks Bob and Thanks fredrik,

Do you think this code would be okay then ?
<?php
$option = JRequest::getString('option');
switch ($option) {
  case 'Asia':
  default:
    $url = 'com_chronocontact&chronoformname=usd_price_iecp';
    break;
  case 'Africa':
    $url = 'com_chronocontact&chronoformname=usd_price_iecp';
    break;
  case 'North America':
    $url = 'com_chronocontact&chronoformname=usd_price_iecp';
    break;
  case 'South America':
    $url = 'com_chronocontact&chronoformname=usd_price_iecp';
    break;
     case 'Australia':
    $url = 'com_chronocontact&chronoformname=usd_price_iecp';
    break;
     case 'Europe':
    $url = 'com_chronocontact&chronoformname=sl200_euro';
    break;
     case 'Antarctica':
    $url = 'com_chronocontact&chronoformname=usd_price_iecp';
    break;
}
$url = 'index.php?option='.$url;
$mainframe->redirect($url);?>
?>


But then it amounts to the same thing. I am a bit confused.

Ron🙄
Ron 30 Mar, 2011
I have made some changes in the code. It seems to work okay. But It redirects to only one case. And that is the first:

<?php
$case = JRequest::getString('case');
switch ($case) {
  case 'Asia':
  default:
    $url = 'com_chronocontact&chronoformname=sl200_euro';
    break;
  case 'Africa':
    $url = 'com_chronocontact&chronoformname=usd_price_iecp';
    break;
  case 'North America':
    $url = 'com_chronocontact&chronoformname=usd_price_iecp';
    break;
  case 'South America':
    $url = 'com_chronocontact&chronoformname=usd_price_iecp';
    break;
     case 'Australia':
    $url = 'com_chronocontact&chronoformname=usd_price_iecp';
    break;
     case 'Europe':
    $url = 'com_chronocontact&chronoformname=sl200_euro';
    break;
     case 'Antarctica':
    $url = 'com_chronocontact&chronoformname=usd_price_iecp';
    break;
}
$url = 'index.php?option='.$url;
$mainframe->redirect($url);?>
?>


Can anyone suggest where I may be making a mistake ?

Thanks

Ron
GreyHead 30 Mar, 2011
Hi Ronn,

What is the Form HTML for the select box (or can you post or PM a link to the form)?

Bob
GreyHead 10 Apr, 2011
Hi Ronn,

The name of the select box in the Form HTML is name='continent' but in the redirect code here you are getting the value of 'case' which is always empty.

Try this version:
<?php
global $mainframe;

$case = JRequest::getString('continent', '', 'post');
//$mainframe->enqueuemessage('$case: '.print_r($case, true).'<hr />');
switch ($case) {
  case 'Asia':
  default:
    $url = 'sl200_euro';
    break;
  case 'Africa':
    $url = 'usd_price_iecp';
    break;
  case 'North America':
    $url = 'usd_price_iecp';
    break;
  case 'South America':
    $url = 'usd_price_iecp';
    break;
     case 'Australia':
    $url = 'usd_price_iecp';
    break;
     case 'Europe':
    $url = 'sl200_euro';
    break;
     case 'Antarctica':
    $url = 'usd_price_iecp';
    break;
}
$url = 'index.php?option=com_chronocontact&chronoformname='.$url;
$mainframe->redirect($url);?>
?>

Bob
Ron 10 Apr, 2011
BOB

Thank you very much.

Ron
GreyHead 11 Apr, 2011
Hi Ron,

Oops, I left a debug line in there - it needs commenting out or deleting:
//$mainframe->enqueuemessage('$case: '.print_r($case, true).'<hr />');

Bob
Ron 14 Apr, 2011
Thanks again Bob,

Things work fine.

Ron :mrgreen:
This topic is locked and no more replies can be posted.