A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: checkbox in mailform getting desperate

  1. #1
    Senior Member
    Join Date
    Nov 2004
    Location
    Amsterdam
    Posts
    212

    checkbox in mailform getting desperate

    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."\n".$email."\n".$tel."\n".$straat."\n".$pla ats."\n".$vraag."\n".$dvd;

    $sendTo = "jeff@winder.demon.nl";
    $subject = "Macro Videoprodukties Emailformulier";

    $headers = "From: " . $_POST["naam"];
    $headers .= "<" . $_POST["email"] . ">\r\n";
    $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
    $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.

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    Unless this is just a typo when posting, you have coded some
    if(a = b) ...
    stuff there. This means that a is set to whatever b is (flse, in your case), and that the result of the operation determines which part of the if/else to run. It is somewhat counter productive. Use == instead

    BTW: you did not like the non-component checkbox that works?

    Musicman

  3. #3
    Senior Member
    Join Date
    Nov 2004
    Location
    Amsterdam
    Posts
    212
    hi Musicman,
    yes , the extra = got lost somewhere, but when i put it back, like
    if (form.dvd.selected=="false")

    or
    if (form.dvd.selected==false)
    (?)
    i still have the same problem of an outcome that is always "yes".

    By the way, I did like your form with non-component elements, but for a Flash/PHP newbie like me, the script looked pretty threatening, and there is some time pressure, so I thought it would be easier for me to try the component checkbox. But I can't tell you how much I appreciate it when people like you take the time to answer my questions, and even post attachments.

    Jerryj

  4. #4
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    according to the maual this thing should read
    if(form.dvd.getValue())
    { something = 'yes';
    }
    else
    { something = 'no';
    }

    I dont think you were really trying to replace the actual checkbox (with instance name form.dvd) by a text variable

    Musicman

  5. #5
    Senior Member
    Join Date
    Nov 2004
    Location
    Amsterdam
    Posts
    212
    YES! (and "no"!)

    Thanks MusicMan, finally I got it working,
    'something' should be form.dvd.
    and I guess I mixed up some things.

    When I have more time, I certainly will take a look at your form again, I like the way you go around using components.

    Thanks!!
    Jerryj.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center