Forums

from checkbox in form to checkbox results in email template

finc 30 Jul, 2009
This is the part of the Form, where I have 3 checkboxes

<table>
<p><tr><td>
	<input type="checkbox" name="check0" value=" I plan to attend the conference" size="5"> I plan to attend the conference<p><tr><td>
	<input type="checkbox" name="check1" value=" I plan to participate and submit a paper" size="5"> I plan to participate and submit a paper
<p><tr><td>
	<input type="checkbox" name="check2" value="Please send me further info on the conference" size="5"> Please send me further info on the conference 


Here is the part in the email template


{check0}  I plan to attend the conference
{check1}  I plan to participate and submit a paper
{check2}  Please send me further info on the conference


I don't get any results, why??
GreyHead 31 Jul, 2009
Hi finc,

You probably just need
{check0}
{check1}
{check2}
in your template - the labels just repeat the values.

Bob
finc 10 Jun, 2010
Yeah thats it:
Adding this to the Email Template
{C1}
{C2}
{C3}
{C4}

I get unchecked results shown as checkbox name??

This 1st one is checked text
{C2}
{C3}
This 4th one is checked text
GreyHead 10 Jun, 2010
Hi finc,

Yes, much discussed here and the code to hide them has been posted a couple of times.

In this case I suggest that you create a checkbox array by using the same array name='check0[]' for each input and putting {check0} in the Tempalte - that way you will only have the problem if they leave all the chackboxes un-checked.

Bob

PS You wil also need to set 'Let ChronoForms handle arrays' to 'Yes' on the form General tab.
finc 10 Jun, 2010
Okay doing that results anyway in one row😟

check0[1]
check0[2]
check0[3]
check0[4]

Results
{check0}
comes in one row
checked box 1 text , checked box 2 text
finc 15 Sep, 2010
any idea why the checked items comes in one row?
GreyHead 15 Sep, 2010
Hi finc,

Because they've been switched from an array into a string. You can manage the array handling yourself and switch it to use <br /> if you prefer.

Bob
finc 05 Jan, 2011
That means I do not let chronoforms handle arrays.
After that how I do it?
{check0}</br> ???
GreyHead 06 Jan, 2011
Hi finc,

Try this in the OnSubmit Before Box:
<?php
$check0 = JRequest::getVar('check0', array(), 'post', 'array');
$check0 = implode('<br />', $check0);
JRequest::setVar('check0', $check0);
?> 

Bob

Later: removed a stray ' from line 2
finc 06 Jan, 2011
took chronoform handles arrays to OFF

pasted Your code into "On Submit code - before sending email:" Box

got this after submit
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in public_html/components/com_chronocontact/libraries/customcode.php(64) : eval()'d code on line 2
GreyHead 06 Jan, 2011
Hi finc,

Apologies, there's a stray ' in this line
$check0 = JRequest::getVar('check0', array()', 'post', 'array');
should be
$check0 = JRequest::getVar('check0', array(), 'post', 'array');

I'll update my first post.

Bob
finc 06 Jan, 2011
ApolloGee accepted!

Working Fine!

Thanks A Lot
This topic is locked and no more replies can be posted.