# Got my checkbox in mailform almost working

**URL:** <https://forum.kirupa.com/t/got-my-checkbox-in-mailform-almost-working/139852>\
**Category:** Uncategorized\
**Created:** [March 6, 2005, 10:51am UTC](https://forum.kirupa.com/t/got-my-checkbox-in-mailform-almost-working/139852 "2005-03-06T10:51:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerryj](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@jerryj](https://forum.kirupa.com/u/jerryj)\
**Post date:** [March 6, 2005, 10:51am UTC](https://forum.kirupa.com/t/got-my-checkbox-in-mailform-almost-working/139852/1 "2005-03-06T10:51:44Z")

</div>

hello,

I am trying to add a checkbox to my mailform using PHP. When I send the mail,  
the output of the checkbox var (‘dvd’) gets through, but it is always “yes”, no matter whether you click it or not.  
I am using the change Handler (named it “checkState”), and i have tried 'getValue’and ‘selected’, but the problem stays.  
these are the codes:

in the main timeline the change Handler function (i first tried “false”; instead of false, same result):

> function checkState()  
> {  
> if (form.dvd.selected=false)  
> form.dvd = “no”;  
> else  
> form.dvd = “yes”;  
> }

on the submit button:

> on (release) {  
> checkState();  
> form.loadVariables(“email.php”, “POST”);  
> }

PHP code (dvd is from the checkbox, the others are textfields that work fine):

> \<?php

$naam = $\_POST[‘naam’];  
$tel = $\_POST[‘tel’];  
$straat = $\_POST[‘straat’];  
$plaats = $\_POST[‘plaats’];  
$vraag= $\_POST[‘vraag’];  
$dvd= $\_POST[‘dvd’];

$message = $naam."  
“.$email.”  
“.$tel.”  
“.$straat.”  
“.$plaats.”  
“.$vraag.”  
".$dvd;

$sendTo = “[jeff@winder.demon.nl](mailto:jeff@winder.demon.nl)”;  
$subject = “Macro Videoprodukties Emailformulier”;

$headers = "From: " . $\_POST[“naam”];  
$headers .= “\<” . $\_POST[“email”] . "\>  
";  
$headers .= "Reply-To: " . $\_POST[“email”] . "  
";  
$headers .= "Return-Path: " . $\_POST[“email”];

mail($sendTo, $subject, $headers, $message);  
?\>

I searched the forums, got some suggestions for non-component checkboxes, but I just can’t find the answer for this one, so any ideas would be great!

Thank you very much,  
Jerryj.
