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

Submit Form Data to eMail

Status
Not open for further replies.

MaKSiNG

Technical User
Dec 4, 2003
19
Hi All,

I am trying to submit data that I have collected in a form to an eMail.

To do this I am using an image button:
Code:
<img src="[URL unfurl="true"]http://myimage.gif"[/URL] name=btnSubmit id="btnSubmit" alt="Click here to submit feedback" style="CURSOR: hand" onClick="submitForm();" />

My form is defined as follows:
Code:
<form name="frmFlexible" id="frmFlexible" method="post" enctype="text/plain" action="mailto:myemail@mail.com" onSubmit="return submitForm();">

In my function submitForm I am simply doing:
Code:
function submitForm() {
   if (confirm("Are you sure you want to submit this information?")){
   return true;
   document.frmFlexible.submit();
   }
   else {
   alert ("Operation Cancelled.");
   return false;
   }
}

The function is called because the confirmation box is launched and the 'else' operation is successful. However, the 'document.frmFlexible.submit();' doesn't seem to be executed. Is this the wrong syntax for some reason.
I have also tried mistyping 'submit' in the function above and this does not error, so it seems it is ignoring this statement completely.

If I simply do:
Code:
<input type="submit" name="btnSubmit" id="btnSubmit">

This button does exactly what I want it to.

Please help.

Thx,
MaKS
 
Switch:

Code:
return true;
document.frmFlexible.submit();

to:

Code:
document.frmFlexible.submit();
return true;

If you return true first, the submit() line is not reached.

On the other hand, why call submit() at all? Returning true should be enough for the FORM's ACTION to be executed.

--Dave
 
In addition to my above remark, I think I now understand something I didn't understand before.

You do not have a submit-style button currently, but just a button with an onclick='submitForm();' event.

If that is what you want, take out the onsubmit event from the FORM tag and forget about the 'return true' all together. The .submit() call will be enough.

--Dave
 
Thanks for that.

Is it possible to make my button, which bases on an image, into a submit-style button?

Thx,
MaKS
 
I found this from a previous post on this topic:

<input type="image" src="foo.jpg" name="whatever" />

Add to it the onclick event calling submitForm() and you might have what you're after.

Good luck!

--Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top