Hi!
My colleague bought CronoForms Cookbook, and there is an example to choose e-mail according to radio button selected, but he want's to send e-mail according to selected check-boxes.
When i try this code, it only send to first check-box selected.
if user select check-boxes: first and forth, i want to send form to first(at)mail.com and forth(at)mail.com.
Thanks for help!
My colleague bought CronoForms Cookbook, and there is an example to choose e-mail according to radio button selected, but he want's to send e-mail according to selected check-boxes.
When i try this code, it only send to first check-box selected.
<?php
$check0 = JRequest::getString('check0', '', 'post');
$emails = array (
'first' => 'first@mail.com',
'second' => 'second@mail.com',
'third' => 'third@mail.com',
'forth' => 'forth@mail.com'
'fifth' => 'fifth@mail.com'
);
$email_to_use = $emails[$check0];
JRequest::setVar('email_to_use', $email_to_use);
?>
if user select check-boxes: first and forth, i want to send form to first(at)mail.com and forth(at)mail.com.
Thanks for help!
Hi dkulot,
If you have a checkbox array with names like check0, then it will return an array result (not a plain string). If you have 'Let ChronoForms handle arrays' set to 'Yes' then the array will be converted to a string for you.
You need to know exactly which result you are getting to process it correctly.
For an array:
Bob
If you have a checkbox array with names like check0, then it will return an array result (not a plain string). If you have 'Let ChronoForms handle arrays' set to 'Yes' then the array will be converted to a string for you.
You need to know exactly which result you are getting to process it correctly.
For an array:
<?php
// if the result is an array use this
$check0 = JRequest::getVar('check0', array(), 'post', 'array');
// if the result is a string use this
$check0 = JRequest::getString('check0', '', 'post');
$check0 = explode(',', $check0);
// then continue in both cases . . .
$emails = array (
'first' => 'first@mail.com',
'second' => 'second@mail.com',
'third' => 'third@mail.com',
'forth' => 'forth@mail.com'
'fifth' => 'fifth@mail.com'
);
$email_to_use = array();
foreach ( $check0 as $v ) {
$email_to_use = $emails[$v];
}
$email_to_use = implode(',', $email_to_use);
JRequest::setVar('email_to_use', $email_to_use);
?>Bob
This topic is locked and no more replies can be posted.
