Converting a HTML Form to Flash

I’ve searched the forums for about 7-10 pages but nothing turned up, so here’s my problem.

I’m not sure if this is the right forum for this, it could also be placed in server side, but i’m not sure. OK, here it goes.

I have to make a brand new site for some people. Their old site was in regular HTML and the new site has to be in Flash. On the old site they had a mailform and they want to use the same one with the new site. I just can’t get it to work. Here’s what I did so far.

The old HTML code:


<form METHOD="POST" ACTION="/asp/FormMail/FormMail.asp">
      <input type="hidden" name="to" value="[email protected]"><input type="hidden"
      name="template" value="/email.txt"><input type="hidden" name="redirect"
      value="/thanks.htm"><input type="hidden" name="redirectistemplate" value="ON">
<table>
        <tr>
          <td>Bedrijfsnaam: </td>
          <td><input type="text" name="companyname_required" size="36"> *</td>
        </tr>
        <tr>
          <td>For: (name)</td>
          <td><input type="text" name="name_required" size="36"> *</td>
        </tr>
        <tr>
          <td>Afdeling:</td>
          <td><input type="text" name="department" size="36"></td>
        </tr>
        <tr>
          <td>Address:</td>
          <td><input type="text" name="address_required" size="36"> *</td>
        </tr>
        <tr>
          <td>Zipcode:</td>
          <td><input type="text" name="zip1_numeric_required" size="4">
          <input type="text" name="zip2_required" size="2"> *</td>
        </tr>
        <tr>
          <td>City:</td>
          <td><input type="text" name="city_required" size="36"> *</td>
        </tr>
        <tr>
          <td>Telephone:</td>
          <td><input type="text" name="telephone_required" size="36"> *</td>
        </tr>
        <tr>
          <td>E-mail:</td>
          <td><input type="text" name="email" size="36"></td>
        </tr>
        <tr>
          <td>Question:</td>
          <td><textarea name="question" rows="4" cols="30"></textarea></td>
        </tr>
        <tr>
<td><input type="reset" value="erase all">
        <input type="submit" value="send">
</td>
        </tr>
      </table>
    </form>

This code works. The ASP file it points to is somewhere on the server. This mail form is provided by their provider.

In Flash I made the same textfields and gave them variable names exactly like the HTML ones. I also placed a button and gave it the AS code:
[AS]
on(press){
loadVariablesNum(“asp/FormMail/FormMail.asp”,0,“post”);
}
[/AS]

But al of this doesn’t seem to work. Can anybody help me out here? I’m really kind of desperate. I’ve even tried PHP but I don’t think their provider supports PHP.

Thnx in advance

Is your button on the same timeline as the fields?
If not, the vars may not get sent, coz Flash will send out ALL variables from the timeline the loadVariables is called, but none others…
try putting all the form and the button in a separate mailer clip (makes it reusable too)…
When you say “it doesn’t seem to work”, that means what?

It means that when I test in (online) it doesn’t send an email to the specified email adress.

whay about question 1?

O yeah, sorry. Forgot about that one…

All the textFields and the button are in the same frame on the same layer.

could you put a trace() in there instead of the asp call to check exactly what you’re sending?
(in the on(press)…)

I’ll try that first thing in the morning :beam:

Right now…dinnertime!!

I’ll let you know.

bon appetit…dinner?
where’d you live?

If your location is correct, i’d guess about an hour or two, three north from where you are.

Je vive dans les Pays-Bas

(I’m not sure if I got that right, but you get the idea. It’s been a few years since I spoke French)

lol, smakelük, or whatever then…you eat early… :slight_smile:
“Je vis aux Pays-Bas”… and my loc’ should show Paris / France…

Cool! A Frenchman that knows a little Dutch…well close enough anyway…it’s smakelijk.

Anyway, back to Flash.

When I trace it, it shows:
<TEXTFORMAT LEADING=“2”><P ALIGN=“LEFT”><FONT FACE=“Times New Roman” SIZE=“16” COLOR="#000000">dfsdfsdf</FONT></P></TEXTFORMAT>

Where dfsdfsdf is the inputted text.

This is not what I had in mind. I want the trace to show just: dsfdsdf

*edit:
I forgot to disable the ‘render text as HTML’ option.

It works now!!!

Just one more question.
I think I saw your reply in a different thread with a similar question.

Some of the textfields have to contain text before you can send the form. And also, some textfield have to contain numbers.
Any idea how to do this?

Nicht Frenchman, Deutscher, that’s why :slight_smile:
Thanks for the spelling :wink:
Back to Flash:
huh? do you mean checking/validating the input before sending off the data?
If so, fisrt step is, you can already use “restrict” to disable txt/n° input on specific fields, and then you’ll check each input separately based on certain criteria…is this what you wanna do?
Let me know, we’ll speak… :slight_smile:

Yes, that’s what I want. Specific fields can only contain textual input and others can only contain numerical input.
Then I only want to check the email input if it is a valid email address but I don’t know how to do it.

And if all the required fields have been filled in correctly ( some fields are optional ) and the email address is valid, THEN I want to post the data.

edit: typo

Allright, this is what I’ve got so far…

I can restrict the input in some fields to numerical or textual input by using : textField.restrict(“0-9”);

I still don’t know how to check if the (optional) email address is valid.

I figured out that I need two functions.
1 - Check if all required field have been filled
2 - Check if email is entered, and if so, check if it’s a valid one.
If no email is entered, this function returns true also.

If both functions return true, then the variables may be send to the ASP page.

I hope I’m making sense here.

if (emailField.length && emailField.indexOf("@") != -1 && emailField.indexOf(".") != -1) {
	//valid
} else {
	//invalid
}

that’s the most basic check you can perform, I usually test out the contact forms on websites with something like "[email protected]", and most of the time it works, sometimes even “@.” works…
not very precise…
I have this, but not tested:
[AS]/#####################################/
/* Email - Check | Flash MX | 2002 /
/
Sebastian Wichmann /
/
Michael Holl (Holly) /
/
http://www.flashhilfe.de /
/
#####################################*/

// Email darf nur die folgenden Zeichen enthalten
email_instanz.restrict = “a-zA-Z0-9@._-”;

function email_check() {
if (email.length) {
inhalt = email.split("@");
domain = inhalt[1].split(".");
laenge = domain.length;
return inhalt.length == 2 && inhalt[0].length >= 1 && laenge >= 2 && domain[laenge-2].length >= 3 && domain[laenge-1].length <= 4 && domain[laenge-1].length >= 2 && domain.join().indexOf("_") == -1 ? true : false;
}
return false;
}

// Aufruf Button (Textfeld => Vari.: email, Instanz.: email_instanz)
on (release) {
email_check(_root.email) ? trace(“Email ist OK!”) : trace(“Email ist Fehlerhaft!”);
} [/AS]
(German author… :wink:

lol thast all wrong!!

means what?

Yeah, what does he mean? It works like a charm!!! Only thing I did was change the names so they would make more sense to me, and that was it. Works just fine.

Thnx for all the help…