# Converting a HTML Form to Flash

**URL:** <https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040>\
**Category:** flash\
**Created:** [February 4, 2004, 1:47pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040 "2004-02-04T13:47:05Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![waztone](https://avatars.discourse-cdn.com/v4/letter/w/cdc98d/32.png) [@waztone](https://forum.kirupa.com/u/waztone)\
**Post date:** [February 4, 2004, 1:47pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/1 "2004-02-04T13:47:05Z")

</div>

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:

```auto

<form METHOD="POST" ACTION="/asp/FormMail/FormMail.asp">
      <input type="hidden" name="to" value="info@mailaddress.com"><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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 4, 2004, 3:35pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/2 "2004-02-04T15:35:50Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 4, 2004, 3:47pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/3 "2004-02-04T15:47:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 4, 2004, 3:50pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/4 "2004-02-04T15:50:04Z")

</div>

whay about question 1?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 4, 2004, 3:51pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/5 "2004-02-04T15:51:38Z")

</div>

O yeah, sorry. Forgot about that one…

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 4, 2004, 3:56pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/6 "2004-02-04T15:56:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 4, 2004, 3:57pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/7 "2004-02-04T15:57:59Z")

</div>

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

Right now…dinnertime!!

I’ll let you know.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 4, 2004, 3:59pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/8 "2004-02-04T15:59:01Z")

</div>

bon appetit…dinner?  
where’d you live?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 4, 2004, 4:03pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/9 "2004-02-04T16:03:52Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 4, 2004, 4:05pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/10 "2004-02-04T16:05:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 5, 2004, 10:31am UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/11 "2004-02-05T10:31:12Z")

</div>

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!!!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 5, 2004, 12:43pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/12 "2004-02-05T12:43:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 5, 2004, 8:19pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/13 "2004-02-05T20:19:19Z")

</div>

Nicht Frenchman, Deutscher, that’s why 🙂  
Thanks for the spelling 😉  
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… 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 6, 2004, 8:35am UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/14 "2004-02-06T08:35:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 6, 2004, 3:33pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/15 "2004-02-06T15:33:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 6, 2004, 5:28pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/16 "2004-02-06T17:28:07Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 6, 2004, 8:15pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/17 "2004-02-06T20:15:13Z")

</div>

that’s the most basic check you can perform, I usually test out the contact forms on websites with something like "a@a.com", 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](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… 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 6, 2004, 9:58pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/18 "2004-02-06T21:58:26Z")

</div>

lol thast all wrong!!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 6, 2004, 11:19pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/19 "2004-02-06T23:19:36Z")

</div>

means what?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 18, 2004, 1:32pm UTC](https://forum.kirupa.com/t/converting-a-html-form-to-flash/42040/20 "2004-02-18T13:32:45Z")

</div>

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…
