Forums

Email sent to user based on Radio Button option

awesome 21 Apr, 2011
Hey there, I've got myself a form filled out. I need an email sent to the person filling out the form dependent on what radio button they select.

ie. Radio buttons are Paypal, Bank Wire and Check. They get an email sent to them telling how to do the one the chose to use

While I receive the form with all the details.

Any help would be much appreciated.
GreyHead 21 Apr, 2011
Hi awesome,

Create three email setups which are identical and put the appropriate body content in the corresponding templates. Disbale all three setups in the Email Setup Properties box.

Add this code, or something like it, to the OnSubmit Before Email box.
<?php
$MyForm =& CFChronoForm::getInstance('myformname');
$emails =& CFEMails::getInstance($MyForm->formrow->id);

$type = JRequest::getString('radio0', '', 'post');
switch ( $type ) {
  case 'paypal':
  default:
    $emails->setEmailData(1, 'enabled', '1');
  break;
  case 'bank_wire':
    $emails->setEmailData(2, 'enabled', '1');
  break;
  case 'check':
    $emails->setEmailData(3, 'enabled', '1');
  break;
}
?>
Not tested and will need debugging. You will need to replace form name, input names and values with those in use on your form.

Bob
awesome 21 Apr, 2011
Awesome! Thanks for that. Okay, so I've got my form complete and I've tested it sort of, I only get the results send to myself.

<table style="width: 95%;" border="0" cellspacing="0" cellpadding="5">
<tbody>
<tr>
<td colspan="4">
<h3>Your Information</h3>
</td>
</tr>
<tr>
<td>First Name:</td>
<td><label> <input id="first_name" name="first_name" type="text" /> </label></td>
<td>Last Name:</td>
<td><input id="last_name" name="last_name" type="text" /></td>
</tr>
<td>Initiated name (if applicable):</td>
<td colspan="3"><label> <input id="initiated_name" name="intitiated_name" type="text" /> </label></td>
<tr>
<td>Email Address:</td>
<td colspan="3"><input id="email_address" name="email_address" type="text" /></td>
</tr>
<tr>
<td>Address 1:</td>
<td colspan="3"><input id="address1" name="address1" type="text" /></td>
</tr>
<tr>
<td>Address 2:</td>
<td colspan="3"><input id="address2" name="address2" type="text" /></td>
</tr>
<tr>
<td>City:</td>
<td colspan="3"><input id="city" name="city" type="text" /></td>
</tr>
<tr>
<td>State:</td>
<td><select name="state"> <option value="AL">Alabama</option> <option value="AK">Alaska</option> <option value="AZ">Arizona</option> <option value="AR">Arkansas</option> <option value="CA">California</option> <option value="CO">Colorado</option> <option value="CT">Connecticut</option> <option value="DE">Delaware</option> <option value="FL">Florida</option> <option value="GA">Georgia</option> <option value="HI">Hawaii</option> <option value="ID">Idaho</option> <option value="IL">Illinois</option> <option value="IN">Indiana</option> <option value="IA">Iowa</option> <option value="KS">Kansas</option> <option value="KY">Kentucky</option> <option value="LA">Louisiana</option> <option value="ME">Maine</option> <option value="MD">Maryland</option> <option value="MA">Massachusetts</option> <option value="MI">Michigan</option> <option value="MN">Minnesota</option> <option value="MS">Mississippi</option> <option value="MO">Missouri</option> <option value="MT">Montana</option> <option value="NE">Nebraska</option> <option value="NV">Nevada</option> <option value="NH">New Hampshire</option> <option value="NJ">New Jersey</option> <option value="NM">New Mexico</option> <option value="NY">New York</option> <option value="NC">North Carolina</option> <option value="ND">North Dakota</option> <option value="OH">Ohio</option> <option value="OK">Oklahoma</option> <option value="OR">Oregon</option> <option value="OT">Other</option> <option value="PA">Pennsylvania</option> <option value="RI">Rhode Island</option> <option value="SC">South Carolina</option> <option value="SD">South Dakota</option> <option value="TN">Tennessee</option> <option value="TX">Texas</option> <option value="UT">Utah</option> <option value="VT">Vermont</option> <option value="VA">Virginia</option> <option value="WA">Washington</option> <option value="WV">West Virginia</option> <option value="WI">Wisconsin</option> <option value="WY">Wyoming</option> </select></td>
<td>If other, state</td>
<td><input id="other" maxlength="20" name="other" size="10" type="text" /></td>
</tr>
<tr>
<td>Zip Code</td>
<td><input id="zipcode" maxlength="5" name="zipcode" size="10" type="text" /></td>
  
</tr>
<tr>
<td>Phone Number:</td>
<td colspan="3"><input id="phone_number" name="phone_number" type="text" />
  
    </td>
  
</tr>
<tr>
<td>Age at time of retreat:</td>
<td colspan="3"><input id="age" name="age" type="text" />
  
    </td>
  
</tr>
<tr>
<td>Registration Type:</td>
<td colspan="3"><select name="reg"> <option value="full">Full Retreat</option> <option value="wk">Weekend Retreat</option>  </select></td>
</tr>

<tr>
<td>Payment Type:*</td>
<td colspan="3">
    <input type="radio" name="radio" id="paypal" value="paypal">
    <label for="paypal">PayPal</label>
    <input type="radio" name="radio" id="bank_wire" value="bank_wise">
    <label for="bank_wire">Bank Wire</label>
    <input type="radio" name="radio" id="Check" value="check">
    <label for="check">Check</label>
  </td>
  
</tr>
<tr>
<td colspan="4"><label> <input id="button" name="button" type="submit" value="Submit" /> </label></td>
</tr>
</tbody>
</table>


Do need to create a separate email template to send the registerer an email saying "Thank your registering, you chose X, please go do Y to complete your registration" As I have three separate eamils that need to be sent to the user dependant on their choice, so far I only have the results being sent to me.

Is that hard to do? And how do you go about doing it?
GreyHead 21 Apr, 2011
Hi awesome,

Yes, add a fourth Email Setup, leave it enabled; use a Dynamic To element and put email_address in the box.

Bob
marklandry 22 Sep, 2011
Hey Bob,
Your code for this worked great out of the box. Thanx!
TINTIN 10 Jan, 2012
Hi, Grey head

I'm trying to send a different E-mail based on the choice of the radio buttons made by a user.However, As per the technique that i'm using i only want a phrase change in the email template according to the value of the choice made.
I'm relatively new to Chronoforms and PHP scripting. Following is the HTML code of the Form I'm using:

<link href="http://blueboxglobal.com/blueboxglobal/components/com_chronoforms/css/tooltip.css" rel="stylesheet" type="text/css" /><form action="http://blueboxglobal.com/blueboxglobal/index.php/internship-form?chronoform=Internship_Form&event=submit" name="Internship_Form" id="chronoform_Internship_Form" method="post" enctype="multipart/form-data" class="Chronoform"><div class="ccms_form_element cfdiv_header" id="autoID-a2166514a1f344506abcffb4a0df55bb_container_div"><p><legend style="padding-top: 0px; padding-right: 2px; padding-bottom: 0px; padding-left: 2px; font-weight: bold; font-size: 16px; color: #333333; font-family: DroidSansRegular; line-height: 18px; background-color: #90c8e3;">Internship form</legend></p>

<ol id="rsform_6_page_0" class="formContainer" style="color: #333333; font-family: DroidSansRegular; font-size: 13px; line-height: 18px; background-color: #90c8e3; padding: 0px; margin: 0px;">

<li class="rsform-block rsform-block-intro-text" style="overflow-x: hidden; overflow-y: hidden; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ebf8ff; list-style-type: none; list-style-position: initial; list-style-image: initial; clear: both; background-position: initial initial; background-repeat: initial initial; padding: 5px; margin: 0px;">

<div class="formBody" style="float: left;">We appreciate your interest in wanting to be part of the Bluebox Internship Program. <br /><br />Congratulations, you have been shortlisted. There is just one more step before we invite you for an interview. Please fill out the web form below and click on the submit button. You will then be assigned an interview slot based on your preference. If you are not in Mumbai, we will schedule phone interviews/conference for you.</div>

</li>

</ol>

<p> </p><div class="clear"></div></div><div class="ccms_form_element cfdiv_radio radios_over" id="current_opening_container_div"><label for="Current Opening">Current Openings (Pick one from here and one from the list below, if you qualify)</label><div style="float:left; clear:none;"><input type="radio" name="Current_Opening" id="current_opening_business_development_manager" title="Current Opening" value="Business Development Manager" class="" />
<label for="current_opening_business_development_manager">Business Development Manager</label>
<input type="radio" name="Current_Opening" id="current_opening_content_writer" title="Current Opening" value="Content Writer" class="" />
<label for="current_opening_content_writer">Content Writer</label>
<input type="radio" name="Current_Opening" id="current_opening_front_end_developer_ux_designer" title="Current Opening" value="Front End Developer UX Designer" class="" />
<label for="current_opening_front_end_developer_ux_designer">Front End Developer UX Designer</label>
<input type="radio" name="Current_Opening" id="current_opening_linux_server_mail_sever_administrator" title="Current Opening" value="Linux Server/Mail Sever Administrator" class="" />
<label for="current_opening_linux_server_mail_sever_administrator">Linux Server/Mail Sever Administrator</label>
<input type="radio" name="Current_Opening" id="current_opening_executive_assistant_to_the_ceo" title="Current Opening" value="Executive Assistant to the CEO" class="" />
<label for="current_opening_executive_assistant_to_the_ceo">Executive Assistant to the CEO</label>
</div><div title="Current Openings (Pick one from here and one from the list below, if you qualify)" rel="Pick one from here and one from the list below, if you qualify" class="tooltipimg"><a href="#">?</a></div><div class="clear"></div><div id="error-message-Current_Opening"></div></div><div class="ccms_form_element cfdiv_radio radios_over" id="additional_options_container_div"><label for="Additional options">Additional options for CA, CS, CWA, LLB, CFA, PhD and MBA  (and other post advanced degree holders ONLY)</label><input type="hidden" name="Additional_Options" value="" alt="ghost" />
<div style="float:left; clear:none;"><input type="radio" name="Additional_Options" id="additional_options_international_m_a" title="Additional options" value="International M&A " class="" />
<label for="additional_options_international_m_a">International M&A / Offshore Structuring & Investment Banking Associate</label>
<input type="radio" name="Additional_Options" id="additional_options_investment_banking_intern" title="Additional options" value="Investment Banking Intern" class="" />
<label for="additional_options_investment_banking_intern">Investment Banking Intern</label>
<input type="radio" name="Additional_Options" id="additional_options_consulting_intern" title="Additional options" value="Consulting Intern" class="" />
<label for="additional_options_consulting_intern">Consulting Intern</label>
<input type="radio" name="Additional_Options" id="additional_options_management_intern" title="Additional options" value="Management Intern" class="" />
<label for="additional_options_management_intern">Management Intern - Job Rotation in All Core Areas</label>
</div><div class="clear"></div><div id="error-message-Additional_Options"></div></div><div class="ccms_form_element cfdiv_text label_over" id="autoID-9a0606eda47fccd97eccd2e9e4711b09_container_div"><label>Where did you hear about the internship opportunity?</label><input maxlength="150" size="30" class=" validate['required','alphanum']" title="" type="text" value="" name="Internship_Info" />
<div class="clear"></div><div id="error-message-Internship_Info"></div></div><div class="ccms_form_element cfdiv_text" id="autoID-3c67e7cad2606133c65f070f037d732b_container_div"><label>First Name</label><input maxlength="150" size="30" class=" validate['required','alpha']" title="" type="text" value="" name="First_Name" />
<div class="clear"></div><div id="error-message-First_Name"></div></div><div class="ccms_form_element cfdiv_text" id="autoID-f13683e8be0908957f1fbddcf62a1ad2_container_div"><label>Last Name</label><input maxlength="150" size="30" class=" validate['required','alpha']" title="" type="text" value="" name="Last_Name" />
<div class="clear"></div><div id="error-message-Last_Name"></div></div><div class="ccms_form_element cfdiv_text" id="autoID-8a8ce6157d30668da6969e5b5155958c_container_div"><label>Email</label><input maxlength="150" size="30" class=" validate['required','email']" title="" type="text" value="" name="Email" />
<div class="clear"></div><div id="error-message-Email"></div></div><div class="ccms_form_element cfdiv_text" id="autoID-8f4132388d8d1dea956d54fdad5109c8_container_div"><label>Phone No.</label><input maxlength="150" size="30" class=" validate['required','phone']" title="" type="text" value="" name="Phone" />
<div class="clear"></div><div id="error-message-Phone"></div></div><div class="ccms_form_element cfdiv_text" id="autoID-e28d9f2164bb76994af1436ce5f75e1e_container_div"><label>City you live in currently</label><input maxlength="150" size="30" class=" validate['alpha']" title="" type="text" value="Mumbai" name="City" />
<div class="clear"></div><div id="error-message-City"></div></div><div class="ccms_form_element cfdiv_radio" id="autoID-2917d265a6f2f5b3f44b4450fbd99e89_container_div"><label>Your computer</label><input type="hidden" name="Computer" value="" alt="ghost" />
<div style="float:left; clear:none;"><input type="radio" name="Computer" id="computer_laptop" title="" value="Laptop" class="validate['required']" />
<label for="computer_laptop">Laptop</label>
<input type="radio" name="Computer" id="computer_desktop" title="" value="Desktop" class="validate['required']" />
<label for="computer_desktop">Desktop</label>
<input type="radio" name="Computer" id="computer_both" title="" value="Both" class="validate['required']" />
<label for="computer_both">Both</label>
<input type="radio" name="Computer" id="computer_no" title="" value="No" class="validate['required']" />
<label for="computer_no">I don't have a computer</label>
</div><div class="clear"></div><div id="error-message-Computer"></div></div><div class="ccms_form_element cfdiv_text" id="autoID-8f6989c2047bd4f4b9dc8d925a5ed585_container_div"><label>Name of College or University</label><input maxlength="150" size="30" class=" validate['required','alphanum']" title="" type="text" value="" name="College" />
<div class="clear"></div><div id="error-message-College"></div></div><div class="ccms_form_element cfdiv_text" id="autoID-89d04d8b6f5bb9733e153b7973cb34df_container_div"><label>Degree</label><input maxlength="150" size="30" class="" title="" type="text" value="" name="Degree" />
<div class="clear"></div><div id="error-message-Degree"></div></div><div class="ccms_form_element cfdiv_text" id="autoID-bf42b51675e073c5f9f2c85e47f51e22_container_div"><label>Anticipated Graduation Date</label><input maxlength="150" size="30" class="" title="" type="text" value="" name="Grad_Date" />
<div class="clear"></div><div id="error-message-Grad_Date"></div></div><div class="ccms_form_element cfdiv_select" id="autoID-49ba79aceeef3bc1619e5a8e59720500_container_div"><label>Internship Location</label><select size="1" class="" title="" name="Internship_Location">
<option value="Office" selected="selected">Office-I live in or around Mumbai.</option>
<option value="Home">Home - I do not live in or around Mumbai - I would like to work from home for this internship.</option>
<option value=""></option>
</select>
<div class="clear"></div><div id="error-message-Internship_Location"></div></div><div class="ccms_form_element cfdiv_text" id="autoID-d37213eed1662acb635d6dcf85e52f91_container_div"><label>Internship Period</label><input maxlength="150" size="30" class="" title="" type="text" value="" name="Internship_period" />
<div class="clear"></div><div id="error-message-Internship_period"></div></div><div class="ccms_form_element cfdiv_checkboxgroup radios_over" id="autoID-b008d0165bb4ee15e7dccea1b87f1537_container_div"><label>Availability</label><input type="hidden" name="Availability" value="" alt="ghost" />
<div style="float:left; clear:none;"><input type="checkbox" name="Availability[]" id="availability_monday" title="" value="Monday" class="validate['group[18]']" />
<label for="availability_monday">Monday</label>
<input type="checkbox" name="Availability[]" id="availability_tuesday" title="" value="Tuesday" class="validate['group[18]']" />
<label for="availability_tuesday">Tuesday</label>
<input type="checkbox" name="Availability[]" id="availability_wednesday" title="" value="Wednesday" class="validate['group[18]']" />
<label for="availability_wednesday">Wednesday</label>
<input type="checkbox" name="Availability[]" id="availability_thursday" title="" value="Thursday" class="validate['group[18]']" />
<label for="availability_thursday">Thursday</label>
<input type="checkbox" name="Availability[]" id="availability_friday" title="" value="Friday" class="validate['group[18]']" />
<label for="availability_friday">Friday</label>
<input type="checkbox" name="Availability[]" id="availability_saturday" title="" value="Saturday" class="validate['group[18]']" />
<label for="availability_saturday">Saturday</label>
<input type="checkbox" name="Availability[]" id="availability_sunday" title="" value="Sunday" class="validate['group[18]']" />
<label for="availability_sunday">Sunday</label>
</div><div class="small-message">Please select days that you are available for work, regardless of full time, part time or remote.</div><div class="clear"></div><div id="error-message-Availability"></div></div><div class="ccms_form_element cfdiv_text" id="autoID-c3dcd682bccb7222dadaddc88949d821_container_div"><label>Ave hours per day</label><input maxlength="150" size="30" class="" title="" type="text" value="" name="Avg_hours_per_day" />
<div class="clear"></div><div id="error-message-Avg_hours_per_day"></div></div><div class="ccms_form_element cfdiv_file" id="autoID-6c7056cd2809dcdfd08be6c22e414f49_container_div"><label>Upload your resume</label><input type="hidden" name="File_Upload" value="" alt="ghost" />
<input class=" validate['required']" title="Upload your resume" type="file" name="File_Upload" />
<div class="clear"></div><div id="error-message-File_Upload"></div></div><div class="ccms_form_element cfdiv_header" id="autoID-d9feeba0a92c4692c9a7be0d786670e3_container_div"><p><br /><span style="color: #333333; font-family: DroidSansRegular; font-size: 13px; line-height: 18px; background-color: #ebf8ff;">DECLARATION: </span><br style="color: #333333; font-family: DroidSansRegular; font-size: 13px; line-height: 18px; background-color: #ebf8ff;" /><span style="color: #333333; font-family: DroidSansRegular; font-size: 13px; line-height: 18px; background-color: #ebf8ff;">I declare that all the information provided above are true to the best of my knowledge. </span><br style="color: #333333; font-family: DroidSansRegular; font-size: 13px; line-height: 18px; background-color: #ebf8ff;" /><span style="color: #333333; font-family: DroidSansRegular; font-size: 13px; line-height: 18px; background-color: #ebf8ff;">I promise that if I am awarded the internship, I will execute my assignments and duties to the best of my abilities. </span><br style="color: #333333; font-family: DroidSansRegular; font-size: 13px; line-height: 18px; background-color: #ebf8ff;" /><br style="color: #333333; font-family: DroidSansRegular; font-size: 13px; line-height: 18px; background-color: #ebf8ff;" /><span style="color: #333333; font-family: DroidSansRegular; font-size: 13px; line-height: 18px; background-color: #ebf8ff;">* Please note that while this is an unpaid Internship, we will consider requests for stipend on a case to case basis.</span></p><div class="clear"></div></div><div class="ccms_form_element cfdiv_checkbox" id="autoID-9e84c0af2beafe27d6769cef7b186839_container_div"><input type="hidden" name="Declaration" value="" alt="ghost" />
<input value="1" title="" type="checkbox" class="validate['required'] label_left" name="Declaration" id="declaration" />
<label for="declaration">Declaration</label><div class="small-message">I have read and agree to the above.<br />

</div><div class="clear"></div><div id="error-message-Declaration"></div></div><div class="ccms_form_element cfdiv_submit" id="autoID-cf5754fa87939f8a93f611703286873b_container_div"><input name="Submit" class="" value="Submit" type="submit" />
 <input type='reset' name='reset' value='Reset' /><div class="clear"></div><div id="error-message-Submit"></div></div><input type="hidden" name="7db4150b194ef49a64bb06675c6fe4b0" value="1" /></form>


Based on the choice made in the Current_Opening radio button group i want to send a different link to each user.I've made A hidden field in the form and named it Link so that it takes the value of Link when the choice is made.

Following is the onSubmit-Before Code:

<?php
$radio = JRequest::getString('Current_Opening', '', 'post');
switch ( $radio ) {
  case 'Business Development Manager':
    JRequest::setVar('Link', 'http://blueboxglobal.com/blueboxglobal/index.php/citizenship');
        break;

case 'Content Writer':
    JRequest::setVar('Link', 'http://blueboxglobal.com/blueboxglobal/index.php/careers/content-writer-quiz');
        break;

case 'Front End Developer UX Designer':
    JRequest::setVar('Link', 'http://http://www.blueboxglobal.com/blueboxglobal/index.php/consulting');
        break;

case 'Linux Server/Mail Sever Administrator':
    JRequest::setVar('Link', 'http://http://www.blueboxglobal.com/blueboxglobal/index.php/our-firm');
        break;

  case 'Executive Assistant to the CEO':
  default:
    JRequest::setVar('Link', 'http://blueboxglobal.com/blueboxglobal/index.php/careers/content-writer-quiz');
        break;
}
?>


The email Template is as follows:
<p>Dear {First_Name} {Last_Name} ,</p>
<p>Thank you! {First_Name} , For Exploring Internship Opputunities With Blueboxglobal. We have recieved your application for the post of {Current_Opening}. Before we call you for the interview we would like you to appear for the pre-interview screening test.</p>
<p>Since you have applied for the post of {Current_Opening} and/ or {Additional_Options}, Please click on the following link. Enter your login Credentials that you receive in the mail sent to you.</p>
<p>Test for {Current_Opening} : {Link} </p>
<p>Once you clear the test you will be Called for the Interview.</p>
<p>Thanks & Regards,</p>
<p>ADMIN,</p>
<p>Blueboxglobal Pte Ltd.</p>

However the link variable doesn't take any values and is blank always.

Please help me with the this. Will be very thankful.
GreyHead 10 Jan, 2012
Hi TINTIN,

The JRequest::setVar() method worked for ChronoForms v3 but does not work for CFv4. Instead use
$form->data['Link'] = 'http://blueboxglobal.com/blueboxglobal/index.php/citizenship';

Bob
TINTIN 10 Jan, 2012
Hi Greyhead,

The previous suggestion helped. It is now displaying the link in the mail. But the problem is its showing the same link for whatever choice I make, which is :

http://blueboxglobal.com/blueboxglobal/index.php/careers/content-writer-quiz';

However , as I have posted the code below I have placed different links for different radio buttons.

Also ,As you have mentioned in the above posts I had created a field name {Link} in the email template. However it is not taking any value and is displayed as {Link} in the email. SO i introduced a Hidden field in the Registration form named it Link and then i got the above result. however the link is the same for all the choices that i make.

<?php
$radio = "JRequest::getString( 'Current_Opening', '', 'post')";
switch ( $radio ) {
  case 'Business Development Manager':
    $form->data['Link'] = 'http://blueboxglobal.com/blueboxglobal/index.php/citizenship';
        break;

case 'Content Writer':
   $form->data['Link'] = 'http://blueboxglobal.com/blueboxglobal/index.php/careers/content-writer-quiz';
        break;

case 'Front End Developer UX Designer':
   $form->data['Link'] = 'http://www.blueboxglobal.com/blueboxglobal/index.php/consulting';
        break;

case 'Linux Server/Mail Sever Administrator':
   $form->data['Link'] = 'http://www.blueboxglobal.com/blueboxglobal/index.php/financial-services/investing/private-wealth';

  case 'Executive Assistant to the CEO':
  default:
  $form->data['Link'] = 'http://blueboxglobal.com/blueboxglobal/index.php/careers/content-writer-quiz';
        break;
}
?>


Here is the code for Email Template:

<p>Dear {First_Name} {Last_Name} ,</p>
<p>Thank you! {First_Name} , For Exploring Internship Opputunities With Blueboxglobal. We have recieved your application for the post of {Current_Opening}. Before we call you for the interview we would like you to appear for the pre-interview screening test.</p>
<p>Since you have applied for the post of {Current_Opening} and/ or {Additional_Options}, Please click on the following link. Enter your login Credentials that you receive in the mail sent to you.</p>
<p>Test for {Current_Opening} : {Link} </p>
<p>Once you clear the test you will be Called for the Interview.</p>
<p>Thanks & Regards,</p>
<p>ADMIN,</p>
<p>Blueboxglobal Pte Ltd.</p>


PLease help!!!i'm Confused.
TINTIN 10 Jan, 2012
Sorry for the above post. It was a syntactical Error. Thanks a lot Bob!! i owe u a beer🙂😀 😀
TINTIN 11 Jan, 2012
Hey GreyHead,

I need your help.

I have two radio Button Groups as two Different Fields, namely Current_Openings And Additional_Options.
Both Of the fields are not compulsory and the user can either choose an option from Current_Openings And Additional_Options or he can choose both.
I have made two email Templates #1 and #2 one for Current_openings and one for Additional_Options, respectively.I need your help with the code to enable a mail based on what the user chooses. If he chooses Current_Openings only one mail should be sent . If he chooses both . Two emails should be sent.
Also BAsed on the choice he makes in Current_openings or Addtional_Options, a different Link should be sent. which u already help me with.

Im relatively new to PHP, And i dnt know how to include the both codes. Also since i saw the other posts and tested it out. the CFEmails stuff doesnt work with CFV4. Please help!!
Awating your reply.
GreyHead 11 Jan, 2012
Hi TINTIN,

I'd probably use copies of my Email [GH] action to manage this. It has a conditional box that you can use to turn emails on and off depending on the form results. You'd need to add a little Custom Code before the Email actions though to check if there were results for that particular CheckBox group.
<?php
if ( count($form->data['Current_Openings'] ) {
  $form->data['send_email_1'] = 'yes';
} else {
  $form->data['send_email_1'] = '';
}
?>

Then put {send_email_1}::yes in the Condition box for the Email [GH] action.

Repeat for the second email action.

Bob
TINTIN 11 Jan, 2012
Hi Bob, thanks for the above reply. But my problem is not solved. I'm getting the following error:

Parse error: syntax error, unexpected '{' in /home/bluebox2/public_html/blueboxglobal/administrator/components/com_chronoforms/form_actions/custom_code/custom_code.php(18) : eval()'d code on line 6

I'm Using Email_GH itself.My Custom Code before Email is:

<?php

$radio = JRequest::getString( 'Current_Opening', '', 'post');
$radio1 = JRequest::getString( 'Additional_Options', '', 'post');

if ( count($form->data['Current_Opening'] ) {
  $form->data['send_email_1'] = 'yes';
} else {
  $form->data['send_email_1'] = '';
}

if ( count($form->data['Additional_Options'] ) {
  $form->data['send_email_1'] = 'yes';
} else {
  $form->data['send_email_1'] = '';
}

switch ( $radio ) {
  case 'Business Development Manager':
    $form->data['Link'] = 'http://blueboxglobal.com/blueboxglobal/index.php/citizenship';
        break;

case 'Content Writer':
   $form->data['Link'] = 'http://blueboxglobal.com/blueboxglobal/index.php/careers/content-writer-quiz';
        break;

case 'Front End Developer UX Designer':
   $form->data['Link'] = 'http://www.blueboxglobal.com/blueboxglobal/index.php/consulting';
        break;

case 'Linux Server/Mail Sever Administrator':
   $form->data['Link'] = 'http://www.blueboxglobal.com/blueboxglobal/index.php/financial-services/investing/private-wealth';
break;

  case 'Executive Assistant to the CEO':
  default:
  $form->data['Link'] = 'http://blueboxglobal.com/blueboxglobal/index.php/careers/content-writer-quiz';
        break;
}

switch ( $radio1 ) {
  case 'International M&A':
    $form->data['Link1'] = 'http://www.blueboxglobal.com/blueboxglobal/index.php/financial-services/advising/mergers-a-acquisitions';
        break;

case 'Investment Banking Intern':
   $form->data['Link1'] = 'http://www.blueboxglobal.com/blueboxglobal/index.php/financial-services/investing';
        break;

case 'Consulting Intern':
   $form->data['Link1'] = 'http://www.blueboxglobal.com/blueboxglobal/index.php/consulting';
        break;

  case 'Management Intern':
  default:
  $form->data['Link1'] = 'http://www.blueboxglobal.com/blueboxglobal/index.php/energreen-green-energy-renewable';
        break;

}

?>


I wanted to know is this the right way of doin it??? Ive put {send_email_1}:: yes as both the conditions . Please Help!!
I'm new to PHP, i wanted to know whether we can use multiple <?PHP ?> directives in d same code snippet?
OR include multiple custom code before Emails.
Awating ur Reply.
TINTIN 11 Jan, 2012
Hi GreyHead,

I solved the syntactical error, however the actutal problem is still not solved.

Even when i select any choice from only Current_Openings i get both the mails, namely of current openings and Additional_options also. with empty fields for the field ive not selected

Following is the custom code im using befire Email_GH

<?php

$radio = JRequest::getString( 'Current_Opening', '', 'post');
$radio1 = JRequest::getString( 'Additional_Options', '', 'post');

if ( count($form->data['Current_Opening']) ) {
  $form->data['send_email_1'] = 'yes';
switch ( $radio ) {
  case 'Business Development Manager':
    $form->data['Link'] = 'http://blueboxglobal.com/blueboxglobal/index.php/citizenship';
        break;

case 'Content Writer':
   $form->data['Link'] = 'http://blueboxglobal.com/blueboxglobal/index.php/careers/content-writer-quiz';
        break;

case 'Front End Developer UX Designer':
   $form->data['Link'] = 'http://www.blueboxglobal.com/blueboxglobal/index.php/consulting';
        break;

case 'Linux Server/Mail Sever Administrator':
   $form->data['Link'] = 'http://www.blueboxglobal.com/blueboxglobal/index.php/financial-services/investing/private-wealth';
break;

  case 'Executive Assistant to the CEO':
  default:
  $form->data['Link'] = 'http://blueboxglobal.com/blueboxglobal/index.php/careers/content-writer-quiz';
        break;
}
} else {
  $form->data['send_email_1'] = '';
}

if ( count($form->data['Additional_Options']) ) {
  $form->data['send_email_1'] = 'yes';
  switch ( $radio1 ) {
  case 'International M&A':
    $form->data['Link1'] = 'http://www.blueboxglobal.com/blueboxglobal/index.php/financial-services/advising/mergers-a-acquisitions';
        break;

case 'Investment Banking Intern':
   $form->data['Link1'] = 'http://www.blueboxglobal.com/blueboxglobal/index.php/financial-services/investing';
        break;

case 'Consulting Intern':
   $form->data['Link1'] = 'http://www.blueboxglobal.com/blueboxglobal/index.php/consulting';
        break;

  case 'Management Intern':
  default:
  $form->data['Link1'] = 'http://www.blueboxglobal.com/blueboxglobal/index.php/energreen-green-energy-renewable';
        break;

}
} else {
  $form->data['send_email_1'] = '';
}




?>



I have set both conditions in the two EMail_GH options as {send_email_1}::yes. please help me get a solution for this. I'm pretty new to PHP
please help!!!
TINTIN 12 Jan, 2012
the emails are getting sent now. Ive placed custom codes separately before the two mails.
However when i choose only the first radio group. Two mails are sent. One for the first radio group and second mail with empty parameters for the second radio group. How do i solve this problem?
This topic is locked and no more replies can be posted.