form is double-submitting when opening a new window

D

Display Name

the customer I'm developing a site for uses a canned form-parsing page that
allows her to have an email subscription opt-in page add emails to a list
she can manage using a link that you point your HTML form to. the actual
form-parsing page resides on a server that's uneditable to me since it sits
on an inaccessible server.

my problem is more irritating than anything; everything double-submits..

when you submit the form, I've forced a new window to open (using
"target='_blank'" in the FORM tag)
So it works- a new window opens saying "Thank you for signing up [followed
by a JS "close this window" option]

however, it's popping up a 2nd window on top of this first popup with this:
"This address already exists in this list. This record will be updated with
any new information entered."

if I ease up on the need to have the form submit to a new window & have it
just submit to the link within the same original window, this apparent
double-submission doesn't happen, but it kicks people off the site because
this canned form-processing page that the form must point to is very
generic. All it says is "Thank you for submitting" followed by a JS
close.window link saying "Close this window".. and the problem w/ doing it
this way is, when you close the window, you're then closing the browser and
kicking the viewer off of the web site.... pretty annoying from a user's
POV. That's why I need to force the new window.

2 more things
--the JS must run it's client-side error-checking
--using "POST" form method rather than GET so they're passed as form
variables not URL variables


Here is the code...............
You can either go to http://www.smoochya.com/index_matt.htm and view the
source code or look at what I've cut & pasted here... this is the relevant
code to the form-submission page:

*********
function submitForm()
{
var continueToSubmit = true;
if( continueToSubmit && document.optin.OILB_124077.value.length == 0 )
{
continueToSubmit = false;
alert('You must provide a value for AGE.');
document.optin.OILB_124077.focus();
}
if( continueToSubmit && document.optin.OILB_EMAIL.value.length != 0 )
{
var emailValue = document.optin.OILB_EMAIL.value;
if( ( emailValue.indexOf( '@' ) <= 0 ) || ( emailValue.indexOf( '.',
emailValue.indexOf( '@' ) ) <= 0 ) )
{
continueToSubmit = false;
alert('You must provide a valid email address.');
document.optin.OILB_EMAIL.focus();
}
}
if( continueToSubmit && document.optin.OILB_EMAIL.value.length == 0 )
{
continueToSubmit = false;
alert('You must provide a value for EMAIL.');
document.optin.OILB_EMAIL.focus();
}
if( continueToSubmit && document.optin.OILB_FIRSTNAME.value.length == 0 )
{
continueToSubmit = false;
alert('You must provide a value for NAME.');
document.optin.OILB_FIRSTNAME.focus();
}
if( continueToSubmit )
{
document.optin.submit();
}

************

Here is the code to the form tag in the body of the same page:

<FORM NAME='optin' METHOD='POST'
ACTION='http://postsnet.com/app/campaigner/services/optinlist/processoptinre
quest.jsp?oilb=84884235' TARGET="_blank">

**************


And here is the code to the 2nd pre-fabbed form processing page that pops up
saying "this address already exists in this list"

<HTML><HEAD><TITLE>Newsletter Sign Up Form</TITLE>


<SCRIPT LANGUAGE="JAVASCRIPT">
//Determine which CSS file to use
var browser = navigator.appName;
var browserVersion = navigator.appVersion;
var ver5Browser = browserVersion.indexOf("MSIE 5");
var os = navigator.platform;
var ie = "Microsoft Internet Explorer";

var netscape = "Netscape";
var mac = "MacPPC";

var newdoc="";
var newRootString="";
var oldRootString="http://postsnet.com/campaigner_images";
var oldSecureRootString="https://postsnet.com/campaigner_images";
var rootString = document.URL;

// check which protocol the page is, http or https and choose the
appropriate style sheet.
if( rootString.indexOf("https") > 0)
{
newRootString= oldSecureRootString;
}
else
{
newRootString= oldRootString;
}

if(browser == netscape && os != mac)
{
newdoc="<link rel=stylesheet type='text/css'
href="+newRootString+"/Scripts/main_nn_pc.css title=master>";
}
else if(browser == netscape && os == mac)
{
newdoc="<link rel=stylesheet type='text/css'
href="+newRootString+"/Scripts/main_nn_mac.css title=master>";
}
else if(browser == ie && ver5Browser < 0 && os == mac)
{
newdoc="<link rel=stylesheet type='text/css'
href="+newRootString+"/Scripts/main_ie_mac.css title=master>";
}
else if(browser == ie && ver5Browser >= 0 && os == mac)
{
newdoc="<link rel=stylesheet type='text/css'
href="+newRootString+"/Scripts/main_ie5_mac.css title=master>";
}
else
{
newdoc="<link rel=stylesheet type='text/css'
href="+newRootString+"/Scripts/main_ie_pc.css title=master>";
}
document.write(newdoc);
</SCRIPT>

</HEAD>
<BODY BGCOLOR='#FFFFFF'>
<font class='rhmaincopy'><B>Thank you!</B><BR><BR>This address already
exists in this list. This record will be updated with any new information
entered.<BR><BR><A HREF='javascript:window.close();'>close window</A><BR>
</FONT></BODY>
</HTML>
********************************8

Maybe this is something I can't control or even see since it's on some site
that makes (bad) cookie-cutter form parsing pages for a site to point it's
form to... . but if anyone has any ideas for workarounds....

Thanks in advance,
Matt
 
H

Hywel Jenkins

Display Name said:
the customer I'm developing a site for uses a canned form-parsing page that
allows her to have an email subscription opt-in page add emails to a list
she can manage using a link that you point your HTML form to. the actual
form-parsing page resides on a server that's uneditable to me since it sits
on an inaccessible server.

my problem is more irritating than anything; everything double-submits..

when you submit the form, I've forced a new window to open (using
"target='_blank'" in the FORM tag)
So it works- a new window opens saying "Thank you for signing up [followed
by a JS "close this window" option]

however, it's popping up a 2nd window on top of this first popup with this:
"This address already exists in this list. This record will be updated with
any new information entered."
It's because the <form> element is submitting the form, then your
JavaScript function does it, too. Change this

if( continueToSubmit )
{
document.optin.submit();
}

to

if( continueToSubmit )
{
document.optin.submit();
} else return false;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top