Unit 09 - Forms
Working with Forms - Video Lecture
HTML Form Code
<!-- REQUIRED: This form tag must appear exactly as follows: -->
<form method="POST" action="http://fp1.formmail.com/cgi-bin/fm192">
<!-- REQUIRED: Supply your plan, form processor and recipients -->
<input type="hidden" name="_pid" value="123964">
<input type="hidden" name="_fid" value="MAEH1M7T">
<input type="hidden" name="recipient" value="1">
<!-- OPTIONAL: The following two fields will appear in the From: line -->
<tr><td><b>Your Name:</b> </td>
<td><input type="text" name="realname" size=40></td></tr>
<tr><td><b>Your E-Mail:</b> </td>
<td><input type="text" name="email" size=40></td></tr>
<!-- OPTIONAL: Any extra fields you include will appear in message body: -->
<tr><td valign="top"><b>Your Comments:</b> </td>
<td><textarea rows="4" cols="40" name="comments"></textarea></tr>
<tr><td colspan="2" align="right">
<input type="submit" value="Send Us Your Comments"></td></tr>
</form>
ActionScript Code
// Set up tabbing so the you can tab from top field and move down
theName.tabIndex=1;
theEmail.tabIndex=2;
theComment.tabIndex=3;
submit.tabIndex=4;
//define initial variables
var address:String="http://fp1.formmail.com/cgi-bin/fm192";
var url:URLRequest;
var variables:URLVariables = new URLVariables();
function sendForm(event:MouseEvent):void {
//Hidden Variables
variables._pid="123964";
variables._fid="MAEH1M7T";
variables.recipient="1";
variables.subject="Info from my flash form";
variables.recipient="brandon.berman@frontrange.edu";
//Form field variables
variables.realname=theName.text;
variables.email=theEmail.text;
variables.comments=theComment.text;
// open up a URLRequest to the address for the form
url=new URLRequest(address);
// define how the URL request will be made
url.method=URLRequestMethod.POST;
//attach all the variables to the URLRequest
url.data=variables;
navigateToURL(url);
}
submit.addEventListener(MouseEvent.CLICK, sendForm);