Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a radio set, checkbox and option drop to this form

Status
Not open for further replies.

Wulfgen

Technical User
Dec 31, 2004
283
US
Hi all,

I have inherited this flash and php form (other developer) and I had to add an extra 9 fields to it (it originally had just three). I was successful in that endeavor, the form works great.

Now the client wants to add radios, checkboxes and a dropmenu to this....(basically color, style and gender) I have been all over the web and nothing seems to fit. There are some flash form generators out there, but they are either pricey or are asp - I'm using php and the form is in a flash based site.

I cut the fields down a bit so you could see whats going on. How can I add these extra form elements? I'm feeling good to just add fields... I'm outta my league here.

Here is the actionscript on frame 1 - the fields in the fla are named emailField, titleField etc etc - all the fields are called (something)Field - pretty straight forward naming conventions.

Code:
stop();

border_off_focus = 8025975;
border_on_focus = 8030344;
background_off_focus = 16777215;
background_on_focus = 15658734;
inputfield = [nameField, emailField, phoneField, siteField, commentField];
for (var i in inputfield) {
	inputfield[i]._width = 200;
	inputfield[i].border = true;
	inputfield[i].background = true;
	inputfield[i].borderColor = 13421772;
	inputfield[i].backgroundColor = 16777215;
	inputfield[i].setNewTextFormat(myTextFormat);
}
sender = new LoadVars();
receiver = new LoadVars();
submit_btn.onRelease = function() {
	if (nameField.text === "" || (emailField.text === "" || commentField.text === "")) {
		errorField.text = "Please complete the required fields";
	} else {
		indexOfAt = emailField.text.indexOf("@");
		lastIndexOfDot = emailField.text.lastIndexOf(".");
		if (indexOfAt != -1 && lastIndexOfDot != -1) {
			if (lastIndexOfDot < indexOfAt || indexOfAt == 0) {
				errorField.text = "Please verify your email.";
			} else if (lastIndexOfDot > (indexOfAt + 1)) {
				sender.name = nameField.text;
				sender.email = emailField.text;
				sender.site = siteField.text;
				sender.phone = phoneField.text;
				sender.comment = commentField.text;
				receiver.onLoad = function(success) {
					if (success) {
						gotoAndStop(2);
					} else {
						errorField.text = "Problem!! please resubmit";
					}
				};
				sender.sendAndLoad("sendEmail.php", receiver, "POST");
			} else {
				errorField.text = "Make sure your \'@\' and \'.\' place correctly";
			}
		} else {
			errorField.text = "Please enter valid email";
		}
	}
};

and here is the php;
Code:
<?php
//Create a temporary name for accepting the variable sent by Flash
$name =  $_POST['name'];
$email = $_POST['email'];
$website = $_POST['site'];
$phone = $_POST['phone'];
$comment = $_POST['comment'];
//Some fields entered contained whitespace and we dont want them, so use function trim() to
//delete away whitespace
$name=trim($name);
$email=trim($email);
$website=trim($website);
$phone=trim($phone);
////$website=trim($website);

// We use StripSlashes to delete away unwanted backslashes '\'
$comment=StripSlashes($comment);

//We are going to include the website field, and company field insid the $comment here
$message ="My name is: $name\n";
$message .="My email address is: $email\n";
$message .="My telephone number is: $phone\n";
$message .="My website is: $website\n";
$message .="I want to say: $comment";

//Modified this to suit your email address
$sendto='me@mysite.com';

//Modified this for displaying the subject in your mail
$subject="Beanie Contact";

mail($sendto,$subject,$message,"From: $name <$email>") or die("Failure");
 //clear all variables
     $name='';
     $email='';
	 $phone='';
	 $website='';
	 $comment='';
     $message='';
echo ("the form has submitted successfully");

?>
 
I have, I placed them on the stage , but the swf file displays a rectangle only - thats why I figured the script was the issue
 
Ahh yea, I get that


- but when a user clicks on that or... it does a trace or post? or...?

right?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top