There are a few things wrong with your form...

You have the id="Email" on the FormItem - it should be on the TextInput.

The name of your form component is ContactForms.mxml but you try to
instantiate it with <forms:ContactForm id="myContactForm"/> (Note
ContactForms and ContactForm is different).

You cannot set properties of a variable inside a CDATA block. You must
do it in a function (Which is inside the CDATA block). eg.

private function sendMyData():void
{
var obj:Object = new Object();
obj.Name = Name.text;
obj.Email = Email.text;
obj.Message = Message.text;
myContactService.send(obj);
}

and change the button mxml to

<mx:Button label="Contact Us" fontSize="16" click="sendMyData()"/>

--- In flexcoders@yahoogroups.com, "brucewhealton" <[EMAIL PROTECTED]> wrote:
>
> Hello all,
>        Flex is not liking the way I setup the Object in a CDATA block 
> in a Form Component.
>          I have a Form component in a forms subfolder/subdirectory of 
> the src directory/folder.  I have an application in the src folder 
> called FormRequest.mxml and in the forms folder I setup a Form 
> Component that I called ContactForm.mxml
>       My form processor will take variable value pairs and email them 
> to me.  In HTML, I use a form tag and then <input name="name" 
> type="text"/>
>       So, I have in the Form component (which is in the file 
> ContactForms.mxml in the forms subfolder) an HTTPService as such:
> 
>  <mx:HTTPService id="myContactService"
>       url="FormToEmail.php"
>       method="POST"/>
> 
> Then I have 
> 
>       <mx:FormItem label="Name:">
>             <mx:TextInput id="Name" width="195"/>
>        </mx:FormItem>
>        <mx:FormItem id="Email" label="Email:" fontSize="16">
>               <mx:TextInput width="195"/>
>       </mx:FormItem>
>       <mx:FormItem label="Your Message:" fontSize="16">
>               <mx:TextArea id="Message" height="100" width="195"/>
>       </mx:FormItem>
>         <mx:FormItem>
>             <mx:Button label="Contact Us" fontSize="16" 
> click="myContactService.send(obj)"/>
>          </mx:FormItem>
> 
> In the CDATA AS block, I have this:
> var obj:Object = new Object();
>             obj.Name =     Name.text;
>             obj.Email = Email.text;
>             obj.Message = Message.text;
> 
> It doesn't like this, as it gives me an error message on the 2nd, 3rd 
> and 4th lines saying that obj is an undefined property.  Am I missing 
> public or private in front of the var?  Sometimes I get confused when 
> that is left off the code.
> 
> Somehow, I've got to get the Name, Email and Message, that the user 
> types into the Form Items, connected to the obj Object.  Then I have 
> to give it to the FormToEmail.php form processor that takes _POST
> ['inputtextvariable'] 
> It looks for variables of that form in the _POST variable.  In HTML 
> the data comes from the name attribute of the INPUT tag.
> 
> Should all of this be in the ContactForm.mxml component?  This is 
> called from FormRequest.mxml inside a Panel, I have this:
> <mx:Panel title="Contact Us">
>     <forms:ContactForm id="myContactForm"/>
> </mx:Panel>
> 
> Does this sound right?  I mean other than the fact that the Form 
> component is not liking obj, saying it is undefined.  I tried hitting 
> ctrl-space to see if it would add an import for the Object class but 
> it must not be needed. 
> Can anyone explain this more clearly, how to get information from a 
> flex Form tag, representing a Form class, into a _POST[] array 
> variable that the php FormToEmail.php form processor will email to me?
> Thanks,
> Bruce
>


Reply via email to