d_harding
11-10-2006, 12:57 PM
Hi people,
I am trying to create a form which allows you to enter your email address, submit the email address to our email account and then open up a window to view a document which can be downloaded. I can only seem to get it working as far as the following:
1). Submit it and recieve the email or
2). Submit it and recieve the file in a new window.
I cant use both actions in the same code at min. This is what i have so far:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Submit Email to Download</title>
<script language="Javascript" type="text/javascript">
<!-- Hide script from older browsers
function validEmail(email) {
invalidChars = " /:,;"
if (email == "") {
return false
}
for (i=0; i<invalidChars.length; i++) {
badChar = invalidChars.charAt(i)
if (email.indexOf(badChar,0) > -1) {
return false
}
}
atPos = email.indexOf("@",1)
if (atPos == -1) {
return false
}
if (email.indexOf("@",atPos+1) > -1) {
return false
}
periodPos = email.indexOf(".",atPos)
if (periodPos == -1) {
return false
}
if (periodPos+3 > email.length) {
return false
}
return true
}
function submitIt(DownloadForm) {
if (!validEmail(DownloadForm.Email.value)) {
alert("Invalid email address")
DownloadForm.Email.focus()
DownloadForm.Email.select()
return false
}
return true
}
// End hiding script -->
</script>
</head>
<body bgcolor="#FFFFFF">
<h2 align="center">Submit Email To Download File </h2>
<form onsubmit="return submitIt(this)" action="Brouchure.pdf" target="new window" name="DownloadForm">
<table border="0" cellspacing="8" cellpadding="8">
<tr>
<td align="right">
Email Address:
</td>
<td>
<input name="Email" type="text" size="30" />
</td>
</tr>
<tr>
<td valign="top">
</td>
<td>
<p><input type="submit" value="Send" /> <input type="reset" /></p>
</td>
</tr>
</table>
</form>
</body>
</html>
I basicaly want to add a MAILO action as well but like I say I cant make them both work. Have tried numerous ideas such as:
<form onsubmit="return submitIt(this)" action="MAILTO:***@****.co.uk" action="Brochure.pdf" target="new window" name="DownloadForm">
I just cant seem to get the code to see it needs to check an email is entered, send the entered email to the deisgnated email address and then open the file for that person to view. I basically want to be able to contact someone who downloads the file hence the form asking for an email address before the download file can be displayed.
Is this possible?? Any on know how? Or have any ideas? Or another way of doing this?
Cheers
I am trying to create a form which allows you to enter your email address, submit the email address to our email account and then open up a window to view a document which can be downloaded. I can only seem to get it working as far as the following:
1). Submit it and recieve the email or
2). Submit it and recieve the file in a new window.
I cant use both actions in the same code at min. This is what i have so far:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Submit Email to Download</title>
<script language="Javascript" type="text/javascript">
<!-- Hide script from older browsers
function validEmail(email) {
invalidChars = " /:,;"
if (email == "") {
return false
}
for (i=0; i<invalidChars.length; i++) {
badChar = invalidChars.charAt(i)
if (email.indexOf(badChar,0) > -1) {
return false
}
}
atPos = email.indexOf("@",1)
if (atPos == -1) {
return false
}
if (email.indexOf("@",atPos+1) > -1) {
return false
}
periodPos = email.indexOf(".",atPos)
if (periodPos == -1) {
return false
}
if (periodPos+3 > email.length) {
return false
}
return true
}
function submitIt(DownloadForm) {
if (!validEmail(DownloadForm.Email.value)) {
alert("Invalid email address")
DownloadForm.Email.focus()
DownloadForm.Email.select()
return false
}
return true
}
// End hiding script -->
</script>
</head>
<body bgcolor="#FFFFFF">
<h2 align="center">Submit Email To Download File </h2>
<form onsubmit="return submitIt(this)" action="Brouchure.pdf" target="new window" name="DownloadForm">
<table border="0" cellspacing="8" cellpadding="8">
<tr>
<td align="right">
Email Address:
</td>
<td>
<input name="Email" type="text" size="30" />
</td>
</tr>
<tr>
<td valign="top">
</td>
<td>
<p><input type="submit" value="Send" /> <input type="reset" /></p>
</td>
</tr>
</table>
</form>
</body>
</html>
I basicaly want to add a MAILO action as well but like I say I cant make them both work. Have tried numerous ideas such as:
<form onsubmit="return submitIt(this)" action="MAILTO:***@****.co.uk" action="Brochure.pdf" target="new window" name="DownloadForm">
I just cant seem to get the code to see it needs to check an email is entered, send the entered email to the deisgnated email address and then open the file for that person to view. I basically want to be able to contact someone who downloads the file hence the form asking for an email address before the download file can be displayed.
Is this possible?? Any on know how? Or have any ideas? Or another way of doing this?
Cheers