Developer Support »

How can I make my form return values for unchecked checkboxes?  (See more user questions)

That's ok , I'm often in a code fog!

Give it a try, see how it goes.

It's been a while since I wrote the CSV part of the script. I will return
to it with your problem in mind. I haven't heard from other customers about
this. Perhaps not so many are using checkbox values for the CSV file or
perhaps they are using multiple checkboxes with one name, which results in
only one column for the checkbox with multiple values shown for it.

In any event, your feedback is invaluable and will help me to improve the
script. It might be too tricky to put configurations in the script to deal
with a problem like yours, but I could put a page on the support section
about it.

Thanks again.

Charles Sweeney
https://formtoemail.com
The world's easiest feedback script!

----- Original Message -----
Sent: Tuesday, March 17, 2009 11:47 AM
Subject: RE: problem eventually solved. Thanks!

> I'm embarrased to say that I didn't read your previous email message
> carefully. PHP is new to me, and I was in a bit of a code fog. I'm going
> to go back and try it the way you suggest. I hadn't considered the
> possible
> issues with browsers other than IE.
>
>
> -----Original Message-----
> Sent: Tuesday, March 17, 2009 7:33 AM
> Subject: Re: problem eventually solved. Thanks!
>
>
> My pleasure, !
>
> Thanks for the feedback. Didn't you try the $sort_fields option in the
> script, to always put the values in the correct order?
>
> The solution you have settled for, relies on the PHP processing the form
> fields in the order that the browser posts them. If it so happens in all
> instances (with all browsers) that they are posted in the same order, and
> it
> works for you, so much the better but using the $sort_fields option means
> the fields will ALWAYS be dealt with in the correct order.
>
> Using your current solution, if the "emailinfo" checkbox is checked, you
> then have *two* values for "emailinfo" and are just hoping that the
> browser
> posts the correct one "emailshowinfo". If it was me, I would use the code
> I
> gave you and state the fields to be processed, and the order that they
> should be processed with $sort_fields. That way you are not relying on
> the
> browser to send the correct value of two values.
>
> Any questions, just let me know.
>
> Best wishes.
>
> Charles Sweeney
> https://formtoemail.com
> The world's easiest feedback script!
>
> ----- Original Message -----
> Sent: Tuesday, March 17, 2009 9:08 AM
> Subject: problem eventually solved. Thanks!
>
>
>> Hi Charles,
>>
>> I really appreciate your assistance. I followed your suggestion and
>> indeed
>> the unchecked boxes returned a value of "no". Unfortunately, in the CSV
>> file, the results didn't align into the correct columns. Positive values
>> were always placed in the left-most columns, while negative values were
>> pushed to the right. (e.g. when a user clicks only the 3rd checkbox, a
>> "yes"
>> appears in the column for the first checkbox, and "no" appears in the
>> columns for the 2nd and 3rd checkboxes.
>>
>> I was able to find a solution (online) that keeps things aligned. I added
>> a
>> line of code to my form before each checkbox as follows:
>>
>> <input type="hidden" name="emailinfo" value="no" />
>> <input name="emailinfo" type="checkbox" id="emailinfo"
>> value="emailshowinfo" />
>>
>> Everthing works as it should now. Thanks again for your help.
>>
>>
>> -----Original Message-----
>> Sent: Monday, March 16, 2009 4:56 PM
>> Subject: Re: FormToEmail-Pro script
>>
>>
>> Hi
>>
>> Thanks for the info. I can see your problem now.
>>
>> The setting in the script to return all values (blank or otherise) is
>> $show_blank_fields . I don't think that will work with the checkboxes if
>> they are not checked (haven't tested it for a while). This is down to
>> how
>> browsers deal with checkboxes. They are ignored unless checked. You
>> could
>> give it a quick try.
>>
>> This might be a solution. If the checkbox is not checked, the script
>> will
>> give it a value of "no". Put this code in your script:
>>
>> if(!isset($_REQUEST['postcard'])){$_REQUEST['postcard'] = "no";}
>>
>> if(!isset($_REQUEST['emailinfo'])){$_REQUEST['emailinfo'] = "no";}
>>
>> if(!isset($_REQUEST['offers'])){$_REQUEST['offers'] = "no";}
>>
>> There are various places in the code that the above code could be pasted.
>> For simplicity's sake, put it at the start of the code, where the
>> instructoins finish. Locate this code:
>>
>> $errors = array();
>> $attachment_array = array();
>>
>> Paste the new code above the it.
>>
>> If you get any problems with the display order of the form fields, you
>> can
>> enable the $sort_fields option and specifically state the order that the
>> fields are dealt with.
>>
>> I haven't tested this, but it looks ok.
>>
>> Any questions, just let me know.
>>
>> Best wishes.
>>
>> Charles Sweeney
>> https://formtoemail.com
>> The world's easiest feedback script!
>>
>> ----- Original Message -----
>> Sent: Monday, March 16, 2009 8:02 PM
>> Subject: RE: FormToEmail-Pro script
>>
>>
>>>
>>>
>>> Charles,
>>>
>>> Thanks for your response. I do understand that your script doesn't make
>>> forms. I wrote because on your "processing own form" support page it
>>> says
>>> "(Pro version can be configured to return all fields, empty or not)",
>>> but
>>> it
>>> doesn't explain how to create that configuration.
>>>
>>> I'm trying to make several checkboxes return a checked value of "yes"
>>> and
>>> an
>>> unchecked value of "no". When unchecked boxes create no value, the
>>> resulting CSV files contained misaligned data because the empty cell is
>>> replaced by the data in the next column.
>>>
>>> An example of the CSV issue is attached. John Doe checked all three
>>> checkboxes, and his data appears correctly. Jane Johnson left the
>>> "postcard" and "emailinfo" checkboxes unchecked and, as a result, data
>>> from
>>> columns to the right entered the "postcard" and "emailinfo" columns.
>>>
>>> Here's the form code:
>>>
>>> <form id="SignUp" name="SignUp" method="post"
>>> action="formtoemailpro.php">
>>> <p>&nbsp;</p>
>>> <table width="657" height="354" border="1" align="center"
>>> cellpadding="5" bordercolor="#CCCCCC" bgcolor="#F1FFE1"
>>> class="formtables">
>>> <tr>
>>> <th height="36" colspan="2" scope="col"><div align="center"
>>> style="font-size: 9pt">Sign up to receive show schedule information and
>>> exclusive offers.</div></th>
>>> </tr>
>>> <tr>
>>> <td width="255" height="310" scope="col"><label>
>>> <input name="firstname" type="text" class="style1"
>>> id="firstname" size="25" maxlength="25" />
>>> <span class="style38"><br />
>>> <span class="style12 style15 style9" style="font-size:
>>> 9pt">First Name</span></span></label>
>>> <p align="left" style="font-size: 9pt">
>>> <input name="lastname" type="text" class="style1"
>>> id="LastName" size="25" maxlength="25" />
>>> <br />
>>> <span class="style12">Last Name</span></p>
>>> <p align="left" style="font-size: 9pt"><span
>>> class="style12">
>>> <input name="email" type="text" id="email" size="35"
>>> maxlength="35" />
>>> <br />
>>> email address</span></p>
>>> <p align="left" style="font-size: 9pt"><span
>>> class="style12"><span class="style38">
>>> <input name="email2" type="text" id="email2"
>>> size="35"
>>> maxlength="35" />
>>> </span></span><br />
>>> <span class="style12">re-enter your email
>>> address</span></p>
>>> <p align="left" style="font-size: 9pt"><span
>>> class="style12">
>>> <input name="mailingaddress" type="text"
>>> id="MailingAddress" size="35" maxlength="35" />
>>> <br />
>>> Mailing Address</span>
>>> <label></label>
>>> </p></td>
>>> <td width="386" scope="col"><p align="left"
>>> style="font-size:
>>> 9pt">
>>> <input name="city" type="text" id="City" size="20"
>>> maxlength="20" />
>>> <span style="color: #F1FFE1">___</span><span
>>> class="style12" style="font-size: 9pt">
>>> <input name="state" type="text" id="State" size="2"
>>> maxlength="2" />
>>> <span class="style38" style="color:
>>> #F1FFE1">____</span>
>>> <input name="zipcode" type="text" id="Zip Code"
>>> size="5"
>>> maxlength="5" />
>>> </span><br />
>>> <span class="style12">City</span><span class="style12"
>>> style="font-size: 9pt"><span style="color:
>>> #F1FFE1">____________________</span>State<span class="style38"
>>> style="color:
>>> #F1FFE1">_____ _</span> Zip</span></p>
>>> <p align="left" class="style12" style="font-size: 9pt">
>>> <label>
>>> <input name="phone" type="text" id="phone" size="12"
>>> maxlength="12" />
>>> </label>
>>> <br />
>>> Phone (optional)</p>
>>> <p align="center" class="style12" style="font-size:
>>> 9pt">Check all that apply.</p>
>>> <p align="left" style="font-size: 9pt">
>>> <label> </label>
>>> <label></label>
>>> <span class="style12">
>>> <label>
>>> <input name="postcard" type="checkbox" id="postcard"
>>> value="yes" />
>>> </label>
>>> I would like to receive your show schedule
>>> postcards</span>.</p>
>>> <p align="left"> <span style="font-size: 9pt">
>>> <label>
>>> <input name="emailinfo" type="checkbox"
>>> id="emailinfo"
>>> value="yes" />
>>> I would like to receive show information via
>>> email.</label>
>>> </span> </p>
>>> <p align="left"><span style="font-size: 9pt">
>>> <label>
>>> <input name="offers" type="checkbox" id="offers"
>>> value="yes" />
>>> I would like to receive your exclusive offers via
>>> email.</label>
>>> </span> </p>
>>> <p align="left">
>>> <label>
>>> <input type="submit" name="submit" id="submit"
>>> value="Submit" />
>>> </label>
>>> </p></td>
>>> </tr>
>>> </table>
>>> <p>&nbsp;</p>
>>> </form>
>>>
>>> If you don't know of a way to make the unchecked boxes create a value of
>>> "no" I'll use my alternative, more clumsy solution. Thanks for your
>>> assistance.
>>>
>>>
>>>
>>> -----Original Message-----
>>> Sent: Monday, March 16, 2009 3:07 PM
>>> Subject: Re: FormToEmail-Pro script
>>>
>>>
>>> Hi
>>>
>>> Thank you for your purchase.
>>>
>>> That's how forms and browsers work. If the checkbox isn't checked, no
>>> value
>>> is sent.
>>>
>>> You could use a drop-down select input with "Yes" and "No" on it.
>>> Defaulting to one or the other.
>>>
>>> My script processes forms, it doesn't make them. You need to make your
>>> own.
>>>
>>> If you give me the URL of your form, I will have a look at it, see if I
>>> have
>>> any ideas. Without seeing it, it might be an idae to give the
>>> checkboxes
>>> different names.
>>>
>>> Best wishes.
>>>
>>> Charles Sweeney
>>> https://formtoemail.com
>>> The world's easiest feedback script!
>>>
>>> ----- Original Message -----
>>> Sent: Monday, March 16, 2009 2:05 PM
>>> Subject: FormToEmail script
>>>
>>>
>>>>
>>>> Comments: I purchased FormToMail Pro. How can I make my form return
>>>> values for unchecked checkboxes?
>>>>
>>>> FormToMail works great for me, except for the CSV file it generates.
>>>> My
>>>> form has 3 consecutive checkboxes. If the first checkbox is left
>>>> unchecked, the results for the second checkbox appear in the column
>>>> for
>>>> the first checkbox. I want my checkboxes to retrun a value "no" if
>>>> unchecked. How is this done?
>>>>
>>>> Thanks.