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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit HTML Form via email

Status
Not open for further replies.

SarahKate31

Programmer
Feb 14, 2002
34
0
0
US
I apologize if this question is already posted...I looked for it...anyway...I have a form on my site that I want users to be able to fill out and have it sent to my email. I used action="mailto:...." in my form tag, but when you press the submit button, it doesn't submit the form, it just opens Outlook with a blank email....Is there a way to do this?

Thanks -- Kate
 
I was afraid that that would be the case...Thanks so much for the quick response.

Cheers -- Kate
 
actually it is possible by javascript and HTML,

this is the javascript and HTML I used for a site that had NO SS scripting (cheap [not my choice])

<script>
function update_message_body()
// This function composes an e-mail message using the contents of another form on the same page.
{
var Title = document.AppointmentForm.Title.value;
var FirstName = document.AppointmentForm.FirstName.value;
var Surname = document.AppointmentForm.Surname.value;
var PhoneNo = document.AppointmentForm.PhoneNo.value;
var PostalAddress = document.AppointmentForm.PostalAddress.value;
var Email = document.AppointmentForm.email.value;
var TimeSlot = document.AppointmentForm.TimeSlot.value;
var CurrentDate = new Date();
document.AppointmentForm.Submitted.value = &quot;True&quot;
document.ProxyForm.MessageBody.value = &quot;\n\n&quot;
+ &quot;Appointment Request&quot; + &quot;\n\n&quot;
+ &quot;Time received: &quot; + CurrentDate + &quot;\n\n&quot;
+ &quot;Name: &quot; + Title + &quot;. &quot; + FirstName + &quot; &quot; + Surname + &quot;\n\n&quot;
+ &quot;Telephone No: &quot; + PhoneNo + &quot;\n\n&quot;
+ &quot;Postal Address: \n\n&quot; + PostalAddress + &quot;\n\n&quot;
+ &quot;E-mail Address: &quot; + Email + &quot;\n\n&quot;
+ &quot;Preferred Time: &quot; + TimeSlot + &quot;\n\n&quot;;
return true;
}
</script>

HTML form
<TABLE>
<FORM name=&quot;AppointmentForm&quot; action=&quot;mailto:email address&quot; enctype=&quot;multipart/form-data&quot;>
<INPUT type=&quot;hidden&quot; name=&quot;Submitted&quot;>
<TR>
<TD>Title:</TD>
<TD>
<SELECT id=&quot;Title&quot;>
<OPTION>Select From...</OPTION>
<OPTION value=&quot;Mr&quot;>Mr</OPTION>
<OPTION value=&quot;Mrs&quot;>Mrs</OPTION>
<OPTION value=&quot;Ms&quot;>Ms</OPTION>
<OPTION value=&quot;Miss&quot;>Miss</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD>First Name:</TD>
<TD>
<INPUT type=&quot;text&quot; size=&quot;30&quot; id=&quot;FirstName&quot;>
</TD>
</TR>
<TR>
<TD>Surname:</TD>
<TD>
<INPUT type=&quot;text&quot; size=&quot;30&quot; id=&quot;Surname&quot;>
</TD>
</TR>
<TR>
<TD>Telephone Number:</TD>
<TD>
<INPUT type=&quot;text&quot; size=&quot;30&quot; id=&quot;PhoneNo&quot;>
</TD>
</TR>
<TR>
<TD>Postal Address:</TD>
<TD rowspan=&quot;2&quot;>
<TEXTAREA cols=&quot;23&quot; rows=&quot;5&quot; id=&quot;PostalAddress&quot;></TEXTAREA>
</TD>
</TR>
<TR>
<TD> </TD>
</TR>
<TR>
<TD>E-mail Address:</TD>
<TD>
<INPUT type=&quot;text&quot; size=&quot;30&quot; name=&quot;email&quot; id=&quot;email&quot;>
</TD>
</TR>
<TR>
<TD>Preferred Time: (AM\PM)</TD>
<TD>
<SELECT id=&quot;TimeSlot&quot; name=&quot;TimeSlot&quot;>
<OPTION>Select From...</OPTION>
<OPTION value=&quot;AM&quot;>AM</OPTION>
<OPTION value=&quot;PM&quot;>PM</OPTION>
<OPTION value=&quot;Sat AM&quot;>Saturday AM</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD> </TD>
<TD> 
</TD>
</TR>
<TR>
<TD> </TD>
<TD> </TD>
</TR>
<TR>
<TD align=&quot;center&quot; colspan=&quot;2&quot;>
<INPUT type=&quot;reset&quot; value=&quot;Reset Form&quot;>
</TD>
</TR>
<TR>
<TD> </TD>
<TD></TD>
</TR>
</FORM>
<FORM name=&quot;ProxyForm&quot; enctype=&quot;text/plain&quot; method=&quot;post&quot; action =&quot;mailto:emai address?subject=some subject&quot; onSubmit=&quot;update_message_body();return true;&quot;>
<TR>
<TD align=&quot;center&quot; colspan=&quot;2&quot;>
<INPUT type=&quot;submit&quot; value=&quot;Request Appointment&quot; name=&quot;submit&quot;>
</TD>
</TR>
<INPUT type=&quot;hidden&quot; id=&quot;MessageBody&quot; name=&quot;MessageBody&quot;>
</FORM>
</TABLE>

You can add or remove fields from the form just remember to add or remove the same ones from the script.
it uses the local mail client to send the message and may popup a warning (depending on the client) so doesn't look terribly professional, but if its all you've got what the hell!

Chris.


Indifference will be the downfall of mankind, but who cares?
 
Kate,

Lookie!

faq215-3358

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
DOH! [hammer]

I should have checked the FAQs first really [reading]

practice what we preach eh!


Chris.




Indifference will be the downfall of mankind, but who cares?
 
It's easier to preach what you practice -- less to remember!

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Wow...thanks Chris and everyone else...Sorry about not checking the FAQ...this site is so big I have trouble finding what I'm looking for sometimes...Thanks again!

Cheers -- Kate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top