...

View Full Version : How to post a form by email which is entered by a user ?



Katrina
01-16-2003, 10:19 AM
hai
i need your help on how to write javascript on my subject.
i wrote some codes on my own and it seems i get stuck.

My subject is: it is an application form for a leave by which a staff enter the email address of his/her supervisor and when click to submit, it send an email to the supervisor with all the information in the form.

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="leave.css" type="text/css">
<link href="" title="Departments">
<link href="" id="Departments">
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var urname=document.eMailer.surname.value
var 1rstname=document.eMailer.first.value
var initialsubj="leave"
var initialmsg="Hi:\n I'm here by applying for a leave. "
var good;
function checkEmailAddress(field) {

var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.co op)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);
if (goodEmail) {
good = true;
}
else {
alert('Please enter a valid address.');
field.focus();
field.select();
good = false;
}
}
u = window.location;
function mailThisUrl() {
good = false
checkEmailAddress(document.eMailer.email);
if (good) {
//window.location = "mailto:"+document.eMailer.email.value+"?subject="+initialsubj+"&body="+document.title+" "+;
window.location = "mailto:"+document.eMailer.email.value+"?subject="+initialsubj+"&body="+ initialmsg
}
}

function validateform()
{
if ((document.eMailer.surname.value=="")||
(document.eMailer.first.value=="")||
(document.eMailer.emp_no.value==""))
{
window.alert ("Please fill out all of the fields!")
return false;
}
}
// End-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<TABLE border="0" width="100%">
<TR>
<TD>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<h3 align=right><a href="Department.html"><font size="+1" color=#336680><i><font size="3">Departments</font></i></font></a>
</h3>
<h3 align=right><a href="staff.html"><font size="+1" color="#336680"><i><font size="3">Staffs</font></i></font></a>
</h3>
<h3 align=right><a href="ripples.html"><font size="+1" color=#336680><i><font size="3">News</font></i></font></a></h3>
<h3 align=right><a href="http://www.namwater.com.na"><font size="+1" color=#336680><i><font size="3">Home</font></i></font></a></h3>
</td>
<TD>

<P align=left><FONT face="Arial, Helvetica, sans-serif" color=#0080ff><B><font size="4" color="#0080FF"><i>Making
Water a Reality</i></font></B></FONT></P>
<hr>
<form name="eMailer" action="emailto:"document.eMailer.email.value"" method=post onSubmit="return validateform( this.form )">
<b>Tell your supervisor:</b>
<input type="text" name="email" size="26" value=" Enter Address Here" onFocus="this.value=''" >
<br>
<P align="center"><B><font size="4">APPLICATION FOR LEAVE</font></B></P>
<p></p>
<TABLE width="100%" align=center border=1 bordercolor="006699" cellpadding=0 cellspacing=0>
<TBODY>
<caption align=left>
<B><FONT color=#0080ff size=4>Identification
- </FONT><FONT color=#336680 size=3>biographical information</FONT></B> </caption>
<TR>
<TD><B>Surname</B>
<INPUT name=surname>
</TD>
<TD><B>First two name</B>
<INPUT name=first>
</TD>
</TR>
<TR>
<TD><B>Employee number</B>
<INPUT size=10 name=emp_no>
</TD>
<TD><B>Identity number</B>
<INPUT name=id_no>
</TD>
</TR>
<TR>
<TD><B>Division</B>
<SELECT name=division>
<OPTION selected>Information system
<OPTION>Mechanical Engineering
<OPTION>Civil Engineering
<OPTION>Electrical Engineering
<OPTION>Electronics Engineering
<OPTION>North East
<OPTION>North West
<OPTION>South</OPTION>
</SELECT>
</TD>
<TD><B>Section</B>
<INPUT name=section>
</TD>
</TR>
<TR>
<TD><B>Location</B>
<INPUT name=location>
</TD>
<TD><B>Department name</B>
<select name=department>
<option
selected>Finance &amp; Administration
<option>Engineering &amp; Scientific Services
<option>Operations</option>
</select>
</TD>
</TR>
</TBODY>
</TABLE>
<P>
<TABLE width="100%" align=center border=1 bordercolor="006699" cellpadding=0 cellspacing=0>
<TBODY>
<caption align=left> <B><FONT color=#0080ff size=4>Types of Absence - </FONT><FONT color=#336680
size=3>Dates of absences</FONT></B> </caption>
<TR>
<TD width="31%"><B>Types</B>
<SELECT name=types>
<OPTION
selected>Vacation
<OPTION>Sick
<OPTION>Maternity
<OPTION>Unpaid Leave
<OPTION>Special Leave
<OPTION>Compassionate Leave</OPTION>
</SELECT>
</TD>
<TD><B>From</B>
<INPUT size=15 name=from>
</TD>
<TD width="21%"><B>To</B>
<INPUT size=15 name=until>
</TD>
<TD width="26%"><B>Days</B>
<input size=17 name=days>
</TD>
</TR>
<TR>
<TD colSpan=4><B><FONT color=#0080ff size=4>Payment request</FONT></B>
</TD>
</TR>
<TR>
<TD colSpan=4><I>Indicate by clicking on the box </I>
<INPUT type=checkbox
value=sal_in_adv name=payment>
<B>Salary in Advance </B>
<INPUT type=checkbox
value=norm_pay_day name=payment>
<B>On normal pay day</B></TD>
</TR>
</TBODY>
</TABLE>
<P>
<TABLE width="100%" align=center border=1 bordercolor="006699" cellpadding=0 cellspacing=0>
<TBODY>
<caption align=left> <B><FONT color=#0080ff size=4>Leave address</FONT></B>
</caption>
<TR>
<TD colSpan=2><B>Contact 1 name</B>
<INPUT name= contact_name1>
</TD>
<TD><B>Telephone</B>
<INPUT size=15 name=contact_tel1>
</TD>
</TR>
<TR>
<TD colSpan=2><B>Contact 2 name</B>
<INPUT name=contact_name2>
</TD>
<TD><B>Telephone</B>
<INPUT size=15 name=contact_tel2>
</TD>
</TR>
<TR>
<TD colSpan=2><B><FONT color=#0080ff size=4>Substitute</FONT></B></TD>
<TD colSpan=2><B>Name</B>
<INPUT name=subs_name>
</TD>
</TR>
</TBODY>
</TABLE>
<P>
<TABLE width="100%" border=1 bordercolor="006699" cellpadding=0 cellspacing=0>
<TBODY>
<caption align=left> <B><FONT color=#0080ff size=4>Authorization</FONT></B></caption>
<TR>
<TD><B>Authorization</B>
<SELECT name=authorization>
<OPTION
selected>Approved
<OPTION>Recommended</OPTION>
</SELECT>
</TD>
<TD>
<INPUT type=checkbox value=yes name=Authority>
<B>Yes</B></TD>
<TD>
<INPUT type=checkbox value=no name=Authority>
<B>No</B></TD>
<TD><B>Name</B>
<INPUT name=by>
</TD>
</TR>
</TBODY>
</TABLE>
<P>
<TABLE height=45 width="100%" border=0>
<TBODY>
<caption align=left> <B><FONT color=#0080ff size=4>Remarks </FONT><FONT
color=#336680>- write comments below</FONT></B></caption>
<TR>
<TD>
<TEXTAREA name=comment rows=5 cols=73></TEXTAREA>
</TD>
</TR>
<tr><td><input type="submit" value="Send your applicatiion" onClick="mailThisUrl();">
<INPUT type=reset value=Clear name=clear></td></tr>
</TBODY>
</TABLE>

</form>
</td>
</tr>
</table>
<hr>
<p>&copy; <font color="#8080C0" size="2"> 2003 Developed by Information
Systems. </font></p>
</body>
</html>
My subject is

arnyinc
01-16-2003, 01:42 PM
Sending an email with a form requires the user to send the email from their own address, so it is usually not the best way to handle the situation. They will receive a warning from their browser and if they don't understand why, they probably won't submit the form.



<html>
<head>
<script language="javascript">
function validateform(myf) {
if (myf.email.value!=""){
myf.action=myf.email.value;
myf.submit();
}
else{
alert('Please enter an email address');
return false;
}
}
</script>
</head>
<body>
<form name="eMailer" onSubmit="validateform(this)">
<input type="text" name="email" value="mailto:youremail@whereever.com">
<input type="submit">
</form>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum