Checkbox Values in Email

mariokrupik 02 May, 2011
Hi,

I am having troubles with an existing Form and it's Checkbox Selections.

There are 6 different checkboxes - like:
<input name="gutscheinart3" type="checkbox" class="schriftgrau" id="gutscheinart3" value="Panoramaflight">


In the Email, if I add all {gutscheinart3} - {gutscheinart4} - ...
next to each other, I do get the value for each Checkbox marked, but all others are shown as written in the template: {gutscheinart3}

As the customer will get a confirmation, I hope that someone can help me with that.
I have looked through the Forum, and found something about the Array Handler, but this seems only to effect Checkbox Groups.

Mario
GreyHead 02 May, 2011
Hi mariokrupik,

A checkbox group is a common way of handling linked checkboxes, in that case the code would be like
<input name="gutscheinart[]" type="checkbox" class="schriftgrau" id="gutscheinart3" value="Panoramaflight">
<input name="gutscheinart[]" type="checkbox" class="schriftgrau" id="gutscheinart4" value="EinAndereflight">

For this you need to use the Handle Array feature to convert the array result into a string.

For the separate checkboxes that you have the problem is that an unchecked box returns nothing at all so there is no value. This means that you need to add the code to identify the missing results and add them. Typically you use something like this in the OnSubmit Before Box for each checkbox:
<?php
$gutscheinart3 = JRequest::getString('gutscheinart3', '', 'post');
JRequest::setVar('gutscheinart3', $gutscheinart3);
?>


Bob
kale 04 May, 2011
Here is my easy solution for a form with one checkbox. Add the following php line to your email template (remember NOT to use it in editor mode):

<?php echo JRequest::getVar('checkboxname', '0', 'post'); ?>

Where checkboxname is the input name of the checkbox in your form. 0 is the value you want to show in the email if the checkbox was not checked.

I tried the solutions found in this forum but still couldn't get it working. After fighting with the problem for couple of hours I came up with the solution above.

Hope this helps!
This topic is locked and no more replies can be posted.