Far Cry Posted June 18, 2010 Share Posted June 18, 2010 I have wrote a simple ticket page but I was wondering how to make it actually send the data to my email: The Code <html> <head> <style type="text/css"> body { background-color:lightGrey; } h1 { color:orange; text-align:center; } font-family:"Times New Roman"; font-size:20px; } </style> </head> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function resetform() { document.forms[0].elements[1]==""; } function submitForms() { if (isEmail() && isFname() && isLname() && isAddress() && isCity() && isState() && isZip()) if (confirm("\n You are about to e-mail your submission. \n\nYES to submit. NO to abort.")) { alert("\nYour submission will now be sent. \n\n Use the Return Button once the submission is complete to return to my home page.\n\n\n Thank you for joining our mailing list!"); return true; } else { alert("\n You have chosen to abort the submission."); return false } else return false; } function isEmail() { if (document.forms[0].elements[1].value == "") { alert ("\n The E-Mail field is blank. \n\n Please enter your E-Mail address.") document.forms[0].elements[1].focus(); return false; } if (document.forms[0].elements[1].value.indexOf ('@',0) == -1 || document.forms[0].elements[1].value.indexOf ('.',0) == -1) { alert ("\n The E-Mail field requires a \"@\" and a \".\"be used. \n\nPlease re-enter your E-Mail address.") document.forms[0].elements[1].select(); document.forms[0].elements[1].focus(); return false; } return true; } function isFname() { if (document.forms[0].elements[2].value == "") { alert ("\n The First Name field is blank. \n\n Please enter your first name.") document.forms[0].elements[2].focus(); return false; } return true; } function isLname() { if (document.forms[0].elements[3].value == "") { alert ("\n The Last Name field is blank. \n\nPlease enter your last name.") document.forms[0].elements[3].focus(); return false; } return true; } } return true; } // End --> </SCRIPT> <BODY> <CENTER> <FORM enctype="text/plain" name="addform" method='get' action='mailto:farcrylatestnewsinwrestling.com?subject=TJS - Mailing List' onSubmit="return submitForms()"> <TABLE border=3 width=430 cellpadding=10><TD align="center"> <strong> <font face="arial" size=+2>Send In a Ticket</font> </strong> </TABLE> <input type="hidden" name="Form" value="Submit Sub"> <TABLE border=3 cellspacing=0 cellpadding=2 bgcolor="#C0C0C0"> <tr valign=baseline> <TD> <font face="arial">Email Address:</font> </TD> <TD> <input type=text name="Email Address" size=35,1 maxlength=80> </TD> </tr> <tr> <TD> <font face="arial">Username:</font> </TD> <TD> <input type=text name="Username" size=35,1 maxlength=80> </TD> </tr> <tr> <TD> Problem?:<br /> <textarea rows="4" cols="23"></textarea><br /> </form> <br> <center> <input type="submit" value=" Submit "> <input type="button" value=" Return " onclick="window.location='sent.htm'"> <input type="reset" value="Reset Form" onclick=resetform()> </FORM> </CENTER> <body> <h1></h1> <p></p> </body> </html> Quote Link to comment Share on other sites More sharing options...
joePHP Posted June 18, 2010 Share Posted June 18, 2010 Hi, JavaScript isn't meant for sending emails. What it basically does, is opens the users e-mail application program like Microsoft Outlook, Thunderbird, AOL etc.. and feels in your email address, subject and the information gathered from the form. If you want to receive emails without having it go through the users e-mail application program, you should use a script written in PHP or ASP. However, I fixed your script to do it's JavaScript part. I'm not sure what you wanted to do with the Return button. <html> <head> <style type="text/css"> body { background-color: #CCC; } h1 { color: orange; text-align: center; font-family: "Times New Roman"; font-size: 20px; } </style> <script type="text/javascript"> <!-- Begin function resetform() { document.forms[0].elements[1]==""; } function submitForms() { if (isEmail() && isFname() && isLname() && isAddress() && isCity() && isState() && isZip()) { if (confirm("\n You are about to e-mail your submission. \n\nYES to submit. NO to abort.")) { alert("\nYour submission will now be sent. \n\n Use the Return Button once the submission is complete to return to my home page.\n\n\n Thank you for joining our mailing list!"); return true; } else { alert("\n You have chosen to abort the submission."); return false } } else { return false; } } function isEmail() { if (document.forms[0].elements[1].value == "") { alert ("\n The E-Mail field is blank. \n\n Please enter your E-Mail address."); document.forms[0].elements[1].focus(); return false; } else { return true; } if (document.forms[0].elements[1].value.indexOf ('@',0) == -1 || document.forms[0].elements[1].value.indexOf ('.',0) == -1) { alert ("\n The E-Mail field requires a \"@\" and a \".\"be used. \n\nPlease re-enter your E-Mail address."); document.forms[0].elements[1].select(); document.forms[0].elements[1].focus(); return false; } else { return true; } } function isFname() { if (document.forms[0].elements[2].value == "") { alert ("\n The First Name field is blank. \n\n Please enter your first name."); document.forms[0].elements[2].focus(); return false; } else { return true; } } function isLname() { if (document.forms[0].elements[3].value == "") { alert ("\n The Last Name field is blank. \n\nPlease enter your last name."); document.forms[0].elements[3].focus(); return false; } else { return true; } } // End --> </script> </head> <body> <center> <form enctype="text/plain" name="addform" method='post' action='mailto:farcrylatestnewsinwrestling.com?subject=TJS - Mailing List' onSubmit="return submitForms();"> <table border="3" width="430" cellpadding="10"> <tr> <td align="center"><strong><font face="arial" size="+2">Send In a Ticket</font></strong></td> </tr> </table> <input type="hidden" name="Form" value="Submit Sub"> <table border="3" cellspacing="0" cellpadding="2" bgcolor="#C0C0C0"> <tr valign="baseline"> <td><font face="arial">Email Address:</font></td> <td><input type="text" name="Email Address" size="35" maxlength="80"> </td> </tr> <tr> <td><font face="arial">Username:</font></td> <td><input type="text" name="Username" size="35" maxlength="80"></td> </tr> <tr> <td>Problem?:<br /> <textarea rows="4" cols="23"></textarea> <br /> <br /> <center> <input type="submit" value=" Submit "> <input type="button" value=" Return " onclick="window.location='sent.htm'"> <input type="reset" value="Reset Form" onclick="resetform();"> </center> </td> <td> </td> </tr> </table> </form> </body> </html> Hope this helps, Joe Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.