form is double-submitting when opening a new window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Display Name

    form is double-submitting when opening a new window

    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 continueToSubmi t = true;
    if( continueToSubmi t && document.optin. OILB_124077.val ue.length == 0 )
    {
    continueToSubmi t = false;
    alert('You must provide a value for AGE.');
    document.optin. OILB_124077.foc us();
    }
    if( continueToSubmi t && document.optin. OILB_EMAIL.valu e.length != 0 )
    {
    var emailValue = document.optin. OILB_EMAIL.valu e;
    if( ( emailValue.inde xOf( '@' ) <= 0 ) || ( emailValue.inde xOf( '.',
    emailValue.inde xOf( '@' ) ) <= 0 ) )
    {
    continueToSubmi t = false;
    alert('You must provide a valid email address.');
    document.optin. OILB_EMAIL.focu s();
    }
    }
    if( continueToSubmi t && document.optin. OILB_EMAIL.valu e.length == 0 )
    {
    continueToSubmi t = false;
    alert('You must provide a value for EMAIL.');
    document.optin. OILB_EMAIL.focu s();
    }
    if( continueToSubmi t && document.optin. OILB_FIRSTNAME. value.length == 0 )
    {
    continueToSubmi t = false;
    alert('You must provide a value for NAME.');
    document.optin. OILB_FIRSTNAME. focus();
    }
    if( continueToSubmi t )
    {
    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><TI TLE>Newsletter Sign Up Form</TITLE>


    <SCRIPT LANGUAGE="JAVAS CRIPT">
    //Determine which CSS file to use
    var browser = navigator.appNa me;
    var browserVersion = navigator.appVe rsion;
    var ver5Browser = browserVersion. indexOf("MSIE 5");
    var os = navigator.platf orm;
    var ie = "Microsoft Internet Explorer";

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

    var newdoc="";
    var newRootString=" ";
    var oldRootString=" http://postsnet.com/campaigner_imag es";
    var oldSecureRootSt ring="https://postsnet.com/campaigner_imag es";
    var rootString = document.URL;

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

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

    </HEAD>
    <BODY BGCOLOR='#FFFFF F'>
    <font class='rhmainco py'><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='javascrip t: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


  • Hywel Jenkins

    #2
    Re: form is double-submitting when opening a new window

    "Display Name" <mmiklas@nyc.rr .com> wrote in message news:<koKkb.758 3$pT1.7185@twis ter.nyc.rr.com> ...[color=blue]
    > 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."
    >[/color]
    It's because the <form> element is submitting the form, then your
    JavaScript function does it, too. Change this

    if( continueToSubmi t )
    {
    document.optin. submit();
    }

    to

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


    --
    Hywel

    Comment

    Working...