Dropdown Box defines email template ?!

stan86 11 May, 2009
Hello,

I'm facing the following problem which I can't solve myself due to a lack of php knowledge.

I have a simple form in which people choose an event through a dropdownbox. The selected value has to determine the email format which they receive in the confirmation mail.

Example:

dropdown value: activity 1 > emailtemplate 1 for conformation email
dropdown value: activity 2 > emailtemplate 2 for conformation email

etc.

Is this possible?

Thanks for any help!
Max_admin 12 May, 2009
Hi stan,

Assuming you have 2 emails with 2 different templates, you may switch them on and off to do what you need, here is a quick code:


$MyForm =& CFChronoForm::getInstance('myformname');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
if($_POST['dropdown_name'] == 'activity1'){
$MyFormEmails->setEmailData(1, 'enabled', '0');//disable email 1
$MyFormEmails->setEmailData(2, 'enabled', '1');//enable email 2
}else{
$MyFormEmails->setEmailData(1, 'enabled', '1');//enable email 1
$MyFormEmails->setEmailData(2, 'enabled', '0');//disable email 2
}


Change form/fields name in my code above based on yours!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
stan86 12 May, 2009
where do I put this code? :?
Max_admin 14 May, 2009
Hi Stan,

in the onSubmit Before email code box!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
mfinley 29 Apr, 2010
I am attempting the same type of thing. When the first condition is met, it is working fine, but when it is one of the other two conditions no email is sent. Here is my code:
$MyForm =& CFChronoForm::getInstance('TestScheduleChange');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
if($_POST['change'] == 'Addition'){
$MyFormEmails->setEmailData(1, 'enabled', '1');//enable email 1
$MyFormEmails->setEmailData(2, 'enabled', '0');//disable email 2
$MyFormEmails->setEmailData(3, 'enabled', '0');//disable email 3
}elseif($_POST['change'] == 'Cancellation'){
$MyFormEmails->setEmailData(1, 'enabled', '0');//disable email 1
$MyFormEmails->setEmailData(2, 'enabled', '1');//enable email 2
$MyFormEmails->setEmailData(3, 'enabled', '0');//disable email 3
}else{
$MyFormEmails->setEmailData(1, 'enabled', '0');//disable email 1
$MyFormEmails->setEmailData(2, 'enabled', '0');//disable email 2
$MyFormEmails->setEmailData(3, 'enabled', '1');//enable email 3
}


Anyone see anything wrong?

Thanks
analographi 11 Jan, 2012
I'm trying this in CF4:

<?php
if($form->data['length'] == "wrong"){

$form->data['email1'] = "xxx@gmail.com"
}

else{
$form->data['email1'] = "{$form->data['email']}"
}


 ?>


doesnt work.. why?
analographi 11 Jan, 2012
ok, got part of it.
Conditional email send for CF4:


<?php
if($form->data['length'] == "wrong"){

$form->data['email1'] = "xxx@gmail.com";
}

else{
$form->data['email1'] = "{$form->data['email']}";
}


 ?>


forgot the ;
its a custom html action in "on submit" before the email action. However all I do is change a variable.

I don't know anything about coding, sorry about me asking in the first place

How can I send either one or the other email?
GreyHead 16 Jan, 2012
Hi analographi,

I can't tell which bit isn't working?? What exactly is the problem?

Bob
This topic is locked and no more replies can be posted.