Forums

Submission is sending all checkboxes selections

treybraid 15 May, 2014
http://xtreme-traction.com/YOUTH/free-publications.html

When I choose my selections and hit submit instead of just the items chosen being sent in the email all are sent.

Any idea what I might be doing wrong?
my form: <label><input type="checkbox" name="newsletter" id="newsletter"></label>

and my email template:
{newsletter}

Thanks
Trey
treybraid 15 May, 2014
I even switched the check boxes to radio buttons and still when i receiving the email everything is included on the form...

trey
treybraid 16 May, 2014
i switched back to check boxes with no success...

after a little searching i found a thread and i inserted custom code before the email action:
<?php
$checkbox_array = array (
'checkbox_field',
// add more checkbox names here
);
foreach ( $checkbox_array as $c ) {
if ( !isset($form->data[$c]) || !$form->data[$c] ) {
$form->data[$c] = 'No'; }}
?>

granted ive got no clue as to what im doing... any help would be much appreciated!!!

trey
GreyHead 16 May, 2014
Hi Trey,

Checkboxes are required to have a 'value' attribute e.g. value='yes' and none of yours do. (Maybe that's not needed in MSWord but it is with real HTML).

Your email template included everything from the Form HTML. I'd suggest that you edit that so that it just shows the titles of the selected items.

Bob
treybraid 16 May, 2014
Bob I went through the form and added the "YES" attribute and the form gets delivered with a yes but all the other choice's are still being included in the form....Is it not possible for just the chosen check boxes to be included in the form? I removed the custom code...

Can you please help me - I'm completely lost here...

Trey
treybraid 16 May, 2014
...if I wanted to add a "checkmark" for the chosen checkbox is that also possible?

thanks
trey
GreyHead 16 May, 2014
Hi Trey,

With a little PHP you could probably add a checkmark - see this StackOverFlow answer for some characters that are reasonably well supported.

Remember that you have ho real control over the fonts that are used in an email reader, and you cannot rely on an image or icon being visible.

Bob
treybraid 16 May, 2014
bob the problem is i really have no idea where to start...my first issue is only having the items chosen being submitted on the form and not all checkboxes... do i need to add back the custom php from my earlier post?

trey
treybraid 16 May, 2014
the biggest hurdle is i don't understand why all the check boxes are being included in the submission email if only 1 is checked... do i need to add custom php to only submit check boxes checked? if so what should i add..

after i get that solved then i want to have a check mark in the chosen box... i need all the help i can get here--- i'm a total newb with this and im completely lost...

trey
GreyHead 16 May, 2014
Hi Trey,

I'd suggest that you do some major cleaning up of the Email template before anything else. Change it so that you just show the Header for each item with a Yes by it if it is ordered.

If you want to set the other items to No or to omit them that will require some fairly simple PHP on the lines of the code you posted - but that is just an example and has to be customised to match your form input names and values.

Bob
treybraid 16 May, 2014
...now I'm completely lost.... ive got no idea what you mean by clean up email headers... i just need the form results emailed to me on submission--- just the items checked... im not a php coder...
GreyHead 17 May, 2014
Hi Trey,

By 'Header' I just meant the label for the item rather than the several paragraphs of description that there are in the form HTML.

Bob
treybraid 17 May, 2014
Thanks Bob... that simplified it tremendously. In fact I added an image to the top of the Thank You and Email Template. Again your help was much appreciated...

For those curious as to what was done.

In the Form itself Bob added a "ghost"
<label><span style="font-size:16px;"><span style="color: rgb(0, 51, 153);"><input id="newsletter_h" name="newsletter" type="hidden" value="no" /> </span></span><input id="newsletter" name="newsletter" type="checkbox" value="yes" /><span style="font-size:16px;"><span style="color: rgb(0, 51, 153);"> <strong>HCYR Corral Newsletter</strong></span></span></label> printed continuously since 1977, this award-winning newsletter is mailed out 6 times each year with all the latest news about children and programs.</div>

Custom Code added in actions:
<?php $checkbox_array = array ( 'checkbox_field' // add more checkbox names here ); foreach ( $checkbox_array as $c ) {
if ( !isset($form->data[$c]) || !$form->data[$c] ) { $form->data[$c] = 'yes'; }} ?>


Then Bob helped out and added: simple headers in the email template---

<div><img src="http://xtreme-traction.com/YOUTH/images/hill/pix/free-publications-tu.jpg" width="920" height="200" /></div> <br />
<div><strong>HCYR Corral newsletter</strong> {newsletter}</div>
<div><strong>HCYR information packet</strong> {packet}</div>
<div><strong>Hill Country Youth Ranch compilation DVD</strong> {hcyrdvd}</div>
<div><strong>Big Springs Ranch for Children compilation DVD</strong> {bsyrdvd}</div>
<div><strong>Macaroni at Midnight</strong> {macaroni}</div>
<div><strong>Prisoner of the Clay CD</strong> {cd_dvd}</div>
<div><strong>Poetry books by children</strong> {poetry_book}</div>
<div><strong>Name</strong> {title} {fname} {lname} {Suffix}</div>
<div><strong>Mailing Address</strong>
{Address}
{Address2}
{City} {State} {Zip} {Country}</div>
<div><strong>Home phone</strong> {Home}</div>
<div><strong>Cell phone</strong> {Cell}</div>
<div><strong>Email</strong> {Email}</div>


I'm still tweaking a couple of things; but, it's finally working....
Thanks

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