Need Help with Form Submission Html code, Can't get a form submit button to work. Newbie Question |
Need Help with Form Submission Html code, Can't get a form submit button to work. Newbie Question |
dnaenthusiast |
May 24 2009, 01:10 PM
Post
#1
|
Group: Members Posts: 1 Joined: 24-May 09 Member No.: 8,696 |
Hey all,
I'm having an issue. I'm trying to code a simple form so that people can enter in their email, phone, etc and when they click submit it will be sent to my email address. I got some code offline that I thought would work, but while the form and everything works, the submit button doesn't work so I don't get the information sent to me. Could someone help me and let me know what's wrong? I substituted emailemail@hotmail.com for where my address i thought was supposed to go. Am i missing another place or did I just make a typing error? <TITLE></TITLE> <script language="javascript"> function SendEmail(frm){ var emailAddress="emailemail@hotmail.com" var message = "name:" + frm.txtName.value + "\n"; message = message +"phone:" + frm.txtold phone.value; message = message +"email:" + frm.txtemail.value; document.location.href = "mailto:"+emailemail@hotmail.com+"?subject=Test Mail&body="+escape(message); } </script> <BODY> <form name="frmSendEmail" > <TABLE> <TR> <TD vAlign=center align=right width="35%"> name: </TD> <TD width="65%"><input type=text name=txtold value=""></TD></TR> <TR> <TD vAlign=center align=right width="35%"> phone: </TD> <TD width="65%"><input type=text name=txtpass value=""></TD></TR> <TR> <TD vAlign=center align=right width="35%"> email: </TD> <TD width="65%"><input type=text name=txtpass value=""></TD></TR> <TR><TD vAlign=center align=center width="100%" colspan=3> <INPUT TYPE="button" name="submit" Value="submit" onclick="SendEmail(this.form)"> </TD></TR> </TABLE> </form> </BODY> |
pandy |
May 24 2009, 04:08 PM
Post
#2
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,733 Joined: 9-August 06 Member No.: 6 |
There are several errors in the script. The quotes are messed up, there are spaces where there should be none, some objects that are referred to don't exist in the form, for example 'txtemail'. It looks like the script is written for another form.
Mailto is always unreliable, so why add to it by submitting the form with JavaScript? Why can't you just use mailto in the action? |
Christian J |
May 24 2009, 04:25 PM
Post
#3
|
. Group: WDG Moderators Posts: 9,661 Joined: 10-August 06 Member No.: 7 |
did I just make a typing error? CODE document.location.href="mailto:emailemail@hotmail.com?subject=Test Mail&body="+escape(message); But see http://htmlhelp.com/faq/html/links.html#mailto-subject and in addition the form depends on javascript being enabled (OTOH this should keep spambots away). See http://htmlhelp.com/faq/html/forms.html#mailto-form for the more reliable solution. This post has been edited by Christian J: May 24 2009, 04:28 PM |
pandy |
May 24 2009, 04:50 PM
Post
#4
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,733 Joined: 9-August 06 Member No.: 6 |
JS may stop bots from submitting the form, but it won't stop them from slurping up the OT's addie...
|
Christian J |
May 25 2009, 08:26 AM
Post
#5
|
. Group: WDG Moderators Posts: 9,661 Joined: 10-August 06 Member No.: 7 |
True, one would have to chop the address up a little to make it harder.
|
Lo-Fi Version | Time is now: 27th April 2024 - 07:01 AM |