Forums

Checkboxes and email template issue

AudioxceL 12 Aug, 2009
Hi, ive been a user of chronoforms for a long time with zero issues, but right now im facing a challenging one.

I have a form that sums the value of the checkboxes via a simple javascript, it shows them to the user when filling the form and also sends this value on the email (no issues here), but when i send the form to an email the fields appear like this:

$ 425.00 ..Responsible Management of Licensed Venues
$ 70.00 ..Responsible Service of Alcohol – RSA
$ {course2} ..Responsible Gambling Services – RGS

If the checkbox is selected, it appears the value of the field, wich is the name of the course to take, but if the checkbox isnt selected, it appears the name of the field, this doesnt happen on any other field, if there is nothing on it on the email it shows a blank space.

Is there any way to make the email show a blank space or a message instead of the field name?

The form code:

<span class="Estilo2">Training Registration Form</span> 
<br />

 <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="10"> </td>
      <td width="150" height="20">Name</td>
      <td width="150">Surname</td>
      <td width="250">Course Name</td>
      <td width="100">Course Date</td>
      <td width="0">Course Location</td>
    </tr>
</table>
  <table width="800" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>   
         <table width="800" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="10">1</td>
        <td width="150"><input type="text" name="name0" id="name0" /></td>
        <td width="150"><input type="text" name="surname0" id="surname0" /></td>
        <td width="250" height="70">
        <span class="Estilo1">
<input onclick="clickCh(this)" type="checkbox" name="course0[]"id="course0" value="425.00">Responsible Management of Licensed Venues<br>
<input onclick="clickCh(this)" type="checkbox" name="course1[]" id="course1" value="70.00">Responsible Service of Alcohol – RSA<br>
<input onclick="clickCh(this)" type="checkbox" name="course2[]" id="course2" value="70.00">Responsible Gambling Services – RGS</span>
</td>
        <td width="100"><input name="date0" type="text" id="date0" size="15" /></td>
        <td><input name="location0" type="text" id="location0" size="14" /></td>
        <td width="50">
        <table width="50" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="50" height="20" background="addextra1.jpg" class="wdc" style="cursor: hand" title="Show/Hide" onclick="change(1)" onMouseOver="style.background='url(addextra0.jpg)';" onMouseOut="style.background='url(addextra1.jpg)'"><a onclick="change(1)" href="#"></a></td>
          </tr>
        </table>
        
        </td>
            
      </tr>
    </table>
    
    <table width="800" border="0" cellspacing="0" cellpadding="0">
        <tr style="display: none" id="1">
        <td width="10">2</td>
        <td width="150"><input type="text" name="name1" id="name1" /></td>
        <td width="150"><input type="text" name="surname1" id="surname1" /></td>
        <td width="250" height="70">
        <span class="Estilo1">
<input onclick="clickCh(this)" type="checkbox" name="course3[]" id="course3" value="425.00">Responsible Management of Licensed Venues<br>
<input onclick="clickCh(this)" type="checkbox" name="course4[]" id="course4" value="70.00">Responsible Service of Alcohol – RSA<br>
<input onclick="clickCh(this)" type="checkbox" name="course5[]" id="course5" value="70.00">Responsible Gambling Services – RGS</span>
</td>
        <td width="100"><input name="date1" type="text" id="date1" size="15" /></td>
        <td><input name="location1" type="text" id="location1" size="14" /></td>
        <td width="50">
        <table width="50" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="50" height="20" background="addextra1.jpg" class="wdc" style="cursor: hand" title="Show/Hide" onclick="change(2)" onMouseOver="style.background='url(addextra0.jpg)';" onMouseOut="style.background='url(addextra1.jpg)'"><a onclick="change(2)" href="#"></a></td>
          </tr>
        </table></td>
            
      </tr>
    </table>
    <table width="800" border="0" cellspacing="0" cellpadding="0">
      <tr style="display: none" id="2">
        <td width="10">3</td>
        <td width="150"><input type="text" name="name2" id="name2" /></td>
        <td width="150"><input type="text" name="surname2" id="surname2" /></td>
        <td width="250" height="70"><span class="Estilo1">
          <input onclick="clickCh(this)" type="checkbox" name="course6[]" id="course6" value="425.00" />
          Responsible Management of Licensed Venues<br />
          <input onclick="clickCh(this)" type="checkbox" name="course7[]" id="course7" value="70.00" />
          Responsible Service of Alcohol – RSA<br />
          <input onclick="clickCh(this)" type="checkbox" name="course8[]" id="course8" value="70.00" />
          Responsible Gambling Services – RGS</span></td>
        <td width="100"><input name="date2" type="text" id="date2" size="15" /></td>
        <td><input name="location2" type="text" id="location2" size="14" /></td>
        <td width="50"><table width="50" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="50" height="20" background="addextra1.jpg" class="wdc" style="cursor: hand" title="Show/Hide" onclick="change(3)" onmouseover="style.background='url(addextra0.jpg)';" onmouseout="style.background='url(addextra1.jpg)'"><a onclick="change(3)" href="#"></a></td>
          </tr>
        </table></td>
      </tr>
    </table>
    <table width="800" border="0" cellspacing="0" cellpadding="0">
      <tr style="display: none" id="3">
        <td width="10">4</td>
        <td width="150"><input type="text" name="name3" id="name3" /></td>
        <td width="150"><input type="text" name="surname3" id="surname3" /></td>
        <td width="250" height="70"><span class="Estilo1">
          <input onclick="clickCh(this)" type="checkbox" name="course9[]" id="course9" value="425.00" />
          Responsible Management of Licensed Venues<br />
          <input onclick="clickCh(this)" type="checkbox" name="course10[]" id="course10" value="70.00" />
          Responsible Service of Alcohol – RSA<br />
          <input onclick="clickCh(this)" type="checkbox" name="course11[]" id="course11" value="70.00" />
          Responsible Gambling Services – RGS</span></td>
        <td width="100"><input name="date3" type="text" id="date3" size="15" /></td>
        <td><input name="location3" type="text" id="location3" size="14" /></td>
        <td width="50"><table width="50" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="50" height="20" background="addextra1.jpg" class="wdc" style="cursor: hand" title="Show/Hide" onclick="change(4)" onmouseover="style.background='url(addextra0.jpg)';" onmouseout="style.background='url(addextra1.jpg)'"><a onclick="change(4)" href="#"></a></td>
          </tr>
        </table></td>
      </tr>
    </table>
    <table width="800" border="0" cellspacing="0" cellpadding="0">
      <tr style="display: none" id="4">
        <td width="10">5</td>
        <td width="150"><input type="text" name="name4" id="name4" /></td>
        <td width="150"><input type="text" name="surname4" id="surname4" /></td>
        <td width="250" height="70"><span class="Estilo1">
          <input onclick="clickCh(this)" type="checkbox" name="course12[]" id="course12" value="425.00" />
          Responsible Management of Licensed Venues<br />
          <input onclick="clickCh(this)" type="checkbox" name="course13[]" id="course13" value="70.00" />
          Responsible Service of Alcohol – RSA<br />
          <input onclick="clickCh(this)" type="checkbox" name="course14[]" id="course14" value="70.00" />
          Responsible Gambling Services – RGS</span></td>
        <td width="100"><input name="date4" type="text" id="date4" size="15" /></td>
        <td><input name="location4" type="text" id="location4" size="14" /></td>
        <td width="50"><table width="50" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="50" height="20" background="addextra1.jpg" class="wdc" style="cursor: hand" title="Show/Hide" onclick="change(5)" onmouseover="style.background='url(addextra0.jpg)';" onmouseout="style.background='url(addextra1.jpg)'"><a onclick="change(5)" href="#"></a></td>
          </tr>
        </table></td>
      </tr>
    </table>
    <table width="800" border="0" cellspacing="0" cellpadding="0">
      <tr style="display: none" id="5">
        <td width="10">6</td>
        <td width="150"><input type="text" name="name5" id="name5" /></td>
        <td width="150"><input type="text" name="surname5" id="surname5" /></td>
        <td width="250" height="70"><span class="Estilo1">
          <input onclick="clickCh(this)" type="checkbox" name="course15[]" id="course15" value="425.00" />
          Responsible Management of Licensed Venues<br />
          <input onclick="clickCh(this)" type="checkbox" name="course16[]" id="course16" value="70.00" />
          Responsible Service of Alcohol – RSA<br />
          <input onclick="clickCh(this)" type="checkbox" name="course17[]" id="course17" value="70.00" />
          Responsible Gambling Services – RGS</span></td>
        <td width="100"><input name="date5" type="text" id="date5" size="15" /></td>
        <td><input name="location5" type="text" id="location5" size="14" /></td>
        <td width="50"><table width="50" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="50" height="20">.</td>
          </tr>
        </table></td>
      </tr>
    </table></td>
      </tr>
</table>

    
  <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td> </td>
    </tr>
  </table>
  <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="25"><label>Licensed Premises Name
          <input name="premisesname" type="text" id="premisesname" size="102" />
      </label></td>
    </tr>
  </table>
  <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="400" height="25"><label>Postal
Address          
    <input name="postal" type="text" id="postal" size="50" />
      </label></td>
      <td width="300"><label>Suburb
          <input name="suburb" type="text" id="suburb" size="35" />
      </label></td>
      <td><label>P/C
          <input name="pc" type="text" id="pc" size="7" />
      </label></td>
    </tr>
  </table>
  <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="400" height="25"><label>Phone Number
          <input name="phone" type="text" id="phone" size="44" />
      </label></td>
      <td><label>Fax Number
          <input name="fax" type="text" id="fax" size="48" />
      </label></td>
    </tr>
  </table>
  <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="500" height="25"><label>Email Address
        <input name="email" type="text" id="email" size="63" />
      </label></td>
      <td><label>Mobile
        <input name="mobile" type="text" id="mobile" size="38" />
      </label></td>
    </tr>
  </table>
  <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="45" class="Estilo2">PAYMENT DETAILS</td>
    </tr>
  </table>
  <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="270" height="25">Do you require a tax invoice?  
      <select name="invoice2" id="invoice2">
        <option>YES</option>
        <option>NO</option>
      </select>
</td>
      <td><label>Name of the Company/Person to be invoiced:
        <input name="invoice" type="text" id="invoice" size="35" />
      </label></td>
    </tr>
  </table>
<table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="45">Please note: Payment  is required in advance to secure a booking.   Paid bookings receive priority over unpaid bookings unless otherwise  arranged.</td>
    </tr>
    <tr>
      <td height="25"><label>Total: $
          <input id="total" type="text" name="total"></label>
</td>
    </tr>
  </table>
  <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="40" class="Estilo2">SEND REGISTRATION FORM </td>
    </tr>
</table>
  <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="400" height="35" valign="middle">Security Image:
      {imageverification}</td>
      <td valign="middle"><input name="I1" value="Submit"
 src="submit.jpg" alt="Submit" height="53"
 type="image" width="80" /></td>
    </tr>
  </table>
  <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="35" align="center" valign="bottom"><strong>Confirmations  will be sent out once payment has been received.</strong></td>
    </tr>
    <tr>
      <td>Training  courses are subject to minimum numbers; payment is required in advance to  secure a booking.  Paid bookings get  priority over unpaid bookings.  Bookings  may be accepted up to one (1) day prior to the commencement of a training  course depending on availability.   Cancellations will be accepted seven (7) days prior to a training course  commencement date, after this time an administration fee of 50% will be  incurred.  No show on the day of the  course will incur a fee of 100% forfeit of monies.  Our training courses are conducted by Matt  Jones or Lisa Jones, approved facilitators with Prosystem Training Services and/or Australian Consulting & Training  Solutions, the OLGR approved<strong> </strong>training  organisations responsible for issuing the qualifications to the participants  who successfully complete our courses.</td>
    </tr>
  </table>

        </style>
        <script type="text/javascript">
function change(id){
     ID = document.getElementById(id);
    
     if(ID.style.display == "")
          ID.style.display = "none";
     else
          ID.style.display = "";
      }
</script>

<script language="JavaScript" type="text/javascript">
var total = document.getElementById("total")
function clickCh(caller){
if(caller.checked){
add(caller)
} else {
subtract(caller)
}
}
function add(caller){ total.value = total.value*1 + caller.value*1}
function subtract(caller){ total.value = total.value*1 - caller.value*1}
</script>


Email template code:

<!--  .class {  	font-weight: bold;  }  -->
<p><strong>Training Registration Form</strong></p>
<table style="width: 800px; font-weight: bold;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="10"></td>
<td width="150" height="20">Name</td>
<td width="150">Surname</td>
<td width="300">Course Name</td>
<td width="100">Course Date</td>
<td width="0">Course Location</td>
</tr>
</tbody>
</table>
<table style="width: 800px; font-weight: normal;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<table style="width: 800px; font-weight: normal;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="10">1</td>
<td width="150">{name0}</td>
<td width="150">{surname0}</td>
<td width="300" height="70">$ {course0} ..Responsible Management of Licensed Venues<br />$ {course1} ..Responsible Service of Alcohol – RSA<br />$ {course2} ..Responsible Gambling Services – RGS</td>
<td width="100">{date0}</td>
<td>{location0}</td>
</tr>
</tbody>
</table>
<table style="width: 800px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="10">2</td>
<td width="150">{name1}</td>
<td width="150">{surname1}</td>
<td width="300" height="70">${course3} ..Responsible Management of Licensed Venues<br />${course4} ..Responsible Service of Alcohol – RSA<br />${course5} ..<span class="Estilo1">Responsible Gambling Services – RGS</span></td>
<td width="100">{date1}</td>
<td>{location1}</td>
</tr>
</tbody>
</table>
<table style="width: 800px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="10">3</td>
<td width="150">{name2}</td>
<td width="150">{surname2}</td>
<td width="300" height="70">${course6} ..Responsible Management of Licensed Venues<br />${course7} ..Responsible Service of Alcohol – RSA<br />${course8} ..Responsible Gambling Services – RGS</td>
<td width="100">{date2}</td>
<td>{location2}</td>
</tr>
</tbody>
</table>
<table style="width: 800px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="10">4</td>
<td width="150">{name3}</td>
<td width="150">{surname3}</td>
<td width="300" height="70">${course9} ..Responsible Management of Licensed Venues<br />${course10} ..Responsible Service of Alcohol – RSA<br />${course11} ..Responsible Gambling Services – RGS</td>
<td width="100">{date3}</td>
<td>{location3}</td>
</tr>
</tbody>
</table>
<table style="width: 800px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="10">5</td>
<td width="150">{name4}</td>
<td width="150">{surname4}</td>
<td width="300" height="70">${course12} ..Responsible Management of Licensed Venues<br />${course13} ..Responsible Service of Alcohol – RSA<br />${course14} ..Responsible Gambling Services – RGS</td>
<td width="100">{date4}</td>
<td>{location4}</td>
</tr>
</tbody>
</table>
<table style="width: 800px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="10">6</td>
<td width="150">{name5}</td>
<td width="150">{surname5}</td>
<td width="300" height="70">${course15} ..Responsible Management of Licensed Venues<br />${course16} ..Responsible Service of Alcohol – RSA<br />${course17} ..Responsible Gambling Services – RGS</td>
<td width="100">{date5}</td>
<td>{location5}</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table style="width: 800px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
<table style="width: 800px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td height="25"><label>Licensed Premises Name: {premisesname} </label></td>
</tr>
</tbody>
</table>
<table style="width: 800px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="300" height="25"><label>Postal Address: {postal} </label></td>
<td width="300"><label>Suburb: {suburb} </label></td>
<td><label>P/C: {pc} </label></td>
</tr>
</tbody>
</table>
<table style="width: 800px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="400" height="25"><label>Phone Number: {phone} </label></td>
<td><label>Fax Number: {fax} </label></td>
</tr>
</tbody>
</table>
<table style="width: 800px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="500" height="25"><label>Email Address: {email} </label></td>
<td><label>Mobile: {mobile} </label></td>
</tr>
</tbody>
</table>
<table style="width: 800px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="Estilo2" height="45">PAYMENT DETAILS</td>
</tr>
</tbody>
</table>
<table style="width: 800px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="270" height="25">Do you require a tax invoice?: {invoice2}</td>
<td><label>Name of the Company/Person to be invoiced: {invoice} </label></td>
</tr>
</tbody>
</table>
<table style="width: 800px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td height="45">Please note: Payment  is required in advance to secure a booking.   Paid bookings receive priority over unpaid bookings unless otherwise  arranged.</td>
</tr>
<tr>
<td height="25"><label>Total: $ {total}</label></td>
</tr>
</tbody>
</table>
<table style="width: 800px;" border="0" cellspacing="0" cellpadding="0">
  <tbody>
  <tr>
  <td height="35" align="center" valign="bottom"><strong>Confirmations  will be sent out once payment has been received.</strong></td>
  </tr>
  <tr>
  <td>Training  courses are subject to minimum numbers; payment is required in advance to  secure a booking.  Paid bookings get  priority over unpaid bookings.  Bookings  may be accepted up to one (1) day prior to the commencement of a training  course depending on availability.   Cancellations will be accepted seven (7) days prior to a training course  commencement date, after this time an administration fee of 50% will be  incurred.  No show on the day of the  course will incur a fee of 100% forfeit of monies.  Our training courses are conducted by Matt  Jones or Lisa Jones, approved facilitators with Prosystem Training Services and/or Australian Consulting & Training  Solutions, the OLGR approved<strong> </strong>training  organisations responsible for issuing the qualifications to the participants  who successfully complete our courses.</td>
  </tr>
  </tbody>
</table>


You can see the form here:
http://www.uniquehospitality.com.au/index.php?option=com_chronocontact&chronoformname=training

If u want to see the email fill the form with your email and it will send you a copy (dynamic to)

Thanks in advance!!
GreyHead 12 Aug, 2009
Hi Audioxcel,

There are two ways of doing this.

1) You can add some PHP in the OnSubmit beofer box to create a result line (blank or text) in a dummy form variable depending on the check-box result.

2) You can do more or less the same thing in the email template.

Both have the same result; personally I'd do it in the Email template to put PHP in there you have to turn off the HTML editor in the Email Setup Properties.

<?php
$check = JRequest::getString('check0', '', 'post');
if ( $check ) {
  echo "$999 Some course or other";
}
?>

Bob
AudioxceL 12 Aug, 2009
Hi, thanks for the response.

Ive added to the onsubmit before like this:

<?php
$check = JRequest::getString('course0', '', 'post');
if ( $check ) {
  echo "$999 Some course or other";
}
?>


But the {course0} still appeared on the email if its not checked.

Iapplied it to the template (and it worked😀 ), butthe code appears if the checkbox is checked, how do i change it to appear if the checkbox isnt checked?

Thanks for the help!
GreyHead 12 Aug, 2009
Hi Aodioxcel,

I'm guessing that the old coe is stil in the template. Please post this part of the tempalte code here so we can take a look.

Bob
mashdun 12 Aug, 2009
I have a form with 10 checkboxes that the user can select services they need. I am creating an email template with a summary of what they filled out on the form and want to show only the checked items and not show the unchecked items. I apologize, I'm a newbie and don't know much about PHP. I want to stick this code in the email only, it won't be saved on a database.

I tried this but cannot get it working:
<?php
$check = JRequest::getString('Service_Needed','Service_Needed2', 'Service_Needed3', 'Service_Needed4', 'Service_Needed5', 'Service_Needed6', 'Service_Needed7', 'Service_Needed8', 'Service_Needed9', 'Service_Needed10','', 'post');
if ( $check ) {
  echo "Selected";
}else{
echo "Not selected";
}
?>


Any help would be much appreciated!
AudioxceL 14 Aug, 2009
Hi mashdun, the problem i see with your code is that it will submit the message ONLY if all the items are selected.

You will have to input a code for each field, this also gives you the advantage to place a check and unchecked message for each field.

ex:


<?php
$check = JRequest::getString('Service_Needed0', '', 'post');
if ( $check ) {
  echo "Selected";
}else{
echo "Not selected";
}
?>
<?php
$check = JRequest::getString('Service_Needed1', '', 'post');
if ( $check ) {
  echo "Selected";
}else{
echo "Not selected";
}
?>
GreyHead 14 Aug, 2009
Hi Mashdun,

I agree with audioxcel, the code you have won't work for a couple of reasons. I'd turn the field list into an array and then loop through the array:
<?php
$field_array = array('Service_Needed','Service_Needed2', 'Service_Needed3', 'Service_Needed4', 'Service_Needed5', 'Service_Needed6', 'Service_Needed7', 'Service_Needed8', 'Service_Needed9', 'Service_Needed10');
foreach ( $field_array as $field ) {
  $check = JRequest::getString($field, '', 'post');
  if ( $check ) {
    echo $field.": Selected";
  } else {
    echo $field.": Not selected";
  }
}
?>
You'd probably need to make this a little more sophisticated to look good.
Bob
This topic is locked and no more replies can be posted.