A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [RESOLVED] Adding a checkbox to an email form?

  1. #1
    Junior Member
    Join Date
    Dec 2008
    Posts
    21

    resolved [RESOLVED] Adding a checkbox to an email form?

    AS 2.0
    Using CS3
    fla file attached

    I am trying to add a checkbox to the form that has to be checked before the send button becomes active. Like (I Agree).

    The code for the whole form is already in place. I just need a couple of lines of AS, on the first frame, to keep the "Send" button from working until the checkbox is clicked.

    I would greatly appreciate any help you can provide.
    Thanks,

    : ) Steve
    Attached Files Attached Files

  2. #2
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    All the following lines of code to your first frame.

    Actionscript Code:
    send_button.onRelease = submit;
    reset_button.onRelease = reset;
    check_box.onPress = checkMe;

    send_button.enabled = false;

    function checkMe()
    {
        if(check_box.checked)
        {
            send_button.enabled = true;
        }
        else
        {
            send_button.enabled = false;
        }
    }
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  3. #3
    Junior Member
    Join Date
    Dec 2008
    Posts
    21
    samac1068,

    Yeeeaaaaaaa!!
    That works great!

    Thank you. I have been working on this form for a week and it's done.

    Also, I am still learning how to write AS and was wondering if this code would be an alternative. In the below script I have just added the (check_box checked = false) under the submit function. This way the message status lets the user know to click the checkbox and it doesn't disable the SEND button. And yea I know it doesn't work because I tested it.

    Thank you for your help

    --Steve


    -----------------------------------------------

    send_button.onRelease = submit;
    reset_button.onRelease = reset;

    function submit()
    {
    if( contact_name.text == "" || contact_email.text == "" ||
    contact_phone.text == "" || contact_message.text == "" )
    {
    message_status.text = "Please fill up all text fields.";
    }
    else if( contact_email.text.indexOf('@') < 2 || contact_email.text.indexOf('.') < 0 )
    {
    message_status.text = "Please enter the valid email address.";
    }
    else if( check_box.checked = false )
    {
    message_status.text = "Please click checkbox.";
    }
    else
    {
    message_status.text = "";
    gotoAndStop("send");
    }
    }
    function reset()
    {
    contact_name.text = contact_email.text = contact_phone.text =
    contact_message.text = message_status.text = "";
    clearInterval(interval_id);
    gotoAndStop("stop");
    }

  4. #4
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    Change one line as followed:
    Actionscript Code:
    else if(!check_box.checked)
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  5. #5
    Junior Member
    Join Date
    Dec 2008
    Posts
    21
    Using ! as "not checked". Got it.
    Awesome thanks.

    sTeve

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