Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to clear input fields on submit?

Community Beginner ,
Jan 13, 2011 Jan 13, 2011

I have this code al set up, but I would like for the input fields and check boxes to clear after submition. How do I do that?

Thank you


import flash.net.URLVariables;
import flash.net.URLRequest;


submit.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event:MouseEvent):void
{
   
   
    if (eMail.text == ""){
        eMail.text = "Please enter in your email address";
    }
    else{
        // Start your custom code
    // create a variable container
    var allVars:URLVariables = new URLVariables();
    allVars.eMail = eMail.text;
    allVars.bead = bead.selected;
    allVars.jewelry = jewelry.selected;
    allVars.onlineNewsletter = onlineNewsletter.selected;
    allVars.sandiegoNewsletter = sandiegoNewsletter.selected;
    //send info to URL
    var mailAddress:URLRequest = new URLRequest("http://www.southsunbeads.com/form.php");
    mailAddress.data = allVars;
    mailAddress.method = URLRequestMethod.POST;
    sendToURL(mailAddress);
        thankyou.text = "Thank you!";
    }
}

TOPICS
ActionScript
1.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 13, 2011 Jan 13, 2011

(Sometimes the timing between us is unbelieveable....  I let this one sit figuring Andrei might have hit it while here earlier, but finding it still unanswered I was just about to post, but checked first just before hitting the Post button...)

Translate
Community Expert ,
Jan 13, 2011 Jan 13, 2011

assign your checkboxes selected property to false and your textfield's text property to "".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 13, 2011 Jan 13, 2011

(Sometimes the timing between us is unbelieveable....  I let this one sit figuring Andrei might have hit it while here earlier, but finding it still unanswered I was just about to post, but checked first just before hitting the Post button...)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2011 Jan 13, 2011

lol.  it's always risky to start answering and then fail to post immediately.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 14, 2011 Jan 14, 2011

Thank you that worked? but I think I'm still doing something wrong because it clear the fields but also the results, so when I get the results back, it shows as marked false when was actually marked true.

Also I'm just getting the results from the boxes but nothign for the email address. Could you please point me in the right direcction with this? Thank you so much...


import flash.net.URLVariables;
import flash.net.URLRequest;

/* Mouse Click Event
Clicking on the specified symbol instance executes a function in which you can add your own custom code.

Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is clicked.
*/


submit.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event:MouseEvent):void
{
   
    if (eMail.text == ""){
        eMail.text = "Please enter in your email address";
   
    }
    else{
        // Start your custom code
        eMail.text = "";
        bead.selected = false;
        jewelry.selected = false;
        onlineNewsletter.selected = false;
        sandiegoNewsletter.selected = false;
    // create a variable container
    var allVars:URLVariables = new URLVariables();
    allVars.eMail = eMail.text;
    allVars.bead = bead.selected;
    allVars.jewelry = jewelry.selected;
    allVars.onlineNewsletter = onlineNewsletter.selected;
    allVars.sandiegoNewsletter = sandiegoNewsletter.selected;
    //send info to URL
    var mailAddress:URLRequest = new URLRequest("http://www.southsunbeads.net/form.php");
    mailAddress.data = allVars;
    mailAddress.method = URLRequestMethod.POST;
    sendToURL(mailAddress);
        thankyou.text = "Thank you!";
    }
}

My php is ....

<?php

// Create local variables from the Flash ActionScript posted variables

$senderEmail = $_POST['eMail'];
$senderNewsletter1 = $_POST['bead'];
$senderNewsletter2 = $_POST['jewelry'];
$senderNewsletter3 = $_POST['onlineNewsletter'];
$senderNewsletter4 = $_POST['sandiegoNewsletter'];

// Strip slashes on the Local typed-in variables for security and run any php based error check here

$senderEmail = stripslashes($eMail);
$senderMessage = stripslashes($senderMessage);


// IMPORTANT - Change these lines to be appropriate for your needs - IMPORTANT !!!!!!!!!!!!!!!!!!
$to = "info@southsunbeads.com";            
$from = "info@southsunbeads.com";
$subject = "Response from game2";
// Modify the Body of the message however you like
$message = "Results from the form:


e-mail: $senderEmail
Bead deal of the day: $senderNewsletter1
Jewelry deal of the day: $senderNewsletter2
online Newsletter: $senderNewsletter3
San Diego Newsletter: $senderNewsletter4


$senderMessage";
// Build $headers Variable
$headers = "From: $from\r\n";
$headers .= "Content-type: text\r\n";
$to = "$to";
    // Send the email
    mail($to, $subject, $message, $headers);
   
    // Assemble the message that goes back to Flash
    // The flash ActionScript is looking for a return variable of "return_msg" there is no sendername in my form, can be just change to generic message
    $my_msg = "Thanks $senderName, all data has been sent.";
    // Print the data back to flash who is patiently waiting for it in the onCompleteHandler
    print "return_msg=$my_msg";
// Exit script   
exit();
?>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 14, 2011 Jan 14, 2011

I may as well earn some of it.... Don't reset the values until after you process them...

function fl_MouseClickHandler(event:MouseEvent):void
{
   
    if (eMail.text == ""){
        eMail.text = "Please enter in your email address";
   
    }

    else{
        // Start your custom code
    // create a variable container
    var allVars:URLVariables = new URLVariables();
    allVars.eMail = eMail.text;
    allVars.bead = bead.selected;
    allVars.jewelry = jewelry.selected;
    allVars.onlineNewsletter = onlineNewsletter.selected;
    allVars.sandiegoNewsletter = sandiegoNewsletter.selected;
    //send info to URL
    var mailAddress:URLRequest = new URLRequest("http://www.southsunbeads.net/form.php");
    mailAddress.data = allVars;
    mailAddress.method = URLRequestMethod.POST;
    sendToURL(mailAddress);
    thankyou.text = "Thank you!";
    }

       eMail.text = "";
        bead.selected = false;
        jewelry.selected = false;
        onlineNewsletter.selected = false;
        sandiegoNewsletter.selected = false;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 14, 2011 Jan 14, 2011

It works!!!!

Thanks a lot!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 14, 2011 Jan 14, 2011
LATEST

You're welcome

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines