By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,620 Members | 1,512 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,620 IT Pros & Developers. It's quick & easy.

Form sending twice

P: n/a
I have a form that calls a perl script. A few javascript routines in
the form do a few things prior to submitting. For some reason,
however, the perl script is being called twice (the perl script sends
out an email, and submitting the form once results in two identical
emails.)

Here are excerpts from the script that I believe to be relevant (I can
post more if this isn't enough, but it's long and I'm trying to keep
it brief.) Can anyone tell me what I'm doing wrong? I've read about
how you need to return true after calling the javascript via a button
click, but I've done this kind of thing in other places and it's
worked fine. I've also tried inserting a return statement here in the
function and it doesn't seem to make a difference. Strange. (BTW, I
changed the domain name in the URL out of courtesy to my client, just
FYI.)

---------

<script language="javascript">
function sendFormNow(theForm)
{
toggleVis ('sendbutton');
toggleVis ('progressbar');

theForm.submit();
}

[...]

<form action="http://cgi.mysitedomain.com/cgi-bin/alertmail.cgi"
method="post">

[...]

<input type="submit" value="send" onClick="sendFormNow(this.form);">

[...]

</form>

---------

Thanks.

--Rick
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
don't submit the form in the JS. the form action is alreadying going to be
doing this for you.
That might be the problem.

"Rick" <in******@hotmail.com> wrote in message
news:b5*************************@posting.google.co m...
I have a form that calls a perl script. A few javascript routines in
the form do a few things prior to submitting. For some reason,
however, the perl script is being called twice (the perl script sends
out an email, and submitting the form once results in two identical
emails.)

Here are excerpts from the script that I believe to be relevant (I can
post more if this isn't enough, but it's long and I'm trying to keep
it brief.) Can anyone tell me what I'm doing wrong? I've read about
how you need to return true after calling the javascript via a button
click, but I've done this kind of thing in other places and it's
worked fine. I've also tried inserting a return statement here in the
function and it doesn't seem to make a difference. Strange. (BTW, I
changed the domain name in the URL out of courtesy to my client, just
FYI.)

---------

<script language="javascript">
function sendFormNow(theForm)
{
toggleVis ('sendbutton');
toggleVis ('progressbar');

theForm.submit();
}

[...]

<form action="http://cgi.mysitedomain.com/cgi-bin/alertmail.cgi"
method="post">

[...]

<input type="submit" value="send" onClick="sendFormNow(this.form);">

[...]

</form>

---------

Thanks.

--Rick

Jul 23 '05 #2

P: n/a
Rick wrote on 23 jun 2004 in comp.lang.javascript:
theForm.submit();
delete this code line

or(!)
<input type="submit" value="send"
onClick="sendFormNow(this.form);">


onClick="sendFormNow(this.form);return false;"
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.