I was just transferring some custom javascript over to chronoforms when I found I needed a dynamic redirect field instead of the 'static' one provided on the control panel.
So I did a minor hack to /components/com_chronocontact/chronocontact.php that I thought I'd share.
In my case, I wanted a dynamic redirect field (i.e. "How do you want to pay? <select name="payment_type" onchange="resetRedirect(this.form)" ><option value="Paypal">Paypal</option><option selected value="check">check</option>" and depending on the answer, the redirect is to the check URL or the paypal URL).
Solution
to FormHTM:
I added a hidden field called redirect
- Code: Select all
<input type="hidden" name="redirect" value="http://mysite.com/thankyou_check.html">
(where http://mysite.com/thankyou_check.html is now the default to match the selected option value above.
to /components/com_chronocontact/chronocontact.php:
I changed the following section:
- Code: Select all
/**
* Redirect the page if requested
*/
if ( !empty($rows[0]->redirecturl) ) {
mosRedirect($rows[0]->redirecturl);
}
to read:
- Code: Select all
/**
* Redirect the page if requested
*/
if ( !empty($fields['redirect']) ) {
mosRedirect($fields['redirect']);
} else {
if ( !empty($rows[0]->redirecturl) ) {
mosRedirect($rows[0]->redirecturl);
}
}
to FormJavaScript:
I added something like
- Code: Select all
function resetRedirect {
var paypalUrl = 'https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=info%40mysite.com&item_name=MyItemName&amount=' 100'¤cy_code=USD&return=http://mysite.com/thankyou_paypal.htm;
if (theForm.payment_type.value == "Paypal"«») {
theForm.redirect.value = paypalUrl;
} else {
theForm.redirect.value = "http://mysite.com/thankyou_check.htm";
}
}
I figure you can do similar hacks to other Chrono fields. Hope this helps some similar situations out there.
STEVE
