form is double-submitting when opening a new window

Discussion in 'HTML' started by Display Name, Oct 20, 2003.

  1. Display Name

    Display Name Guest

    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
    Display Name, Oct 20, 2003
    #1
    1. Advertising

  2. "Display Name" <> wrote in message news:<koKkb.7583$>...
    > 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;


    --
    Hywel
    Hywel Jenkins, Oct 20, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick Olurotimi Ige

    Closing child window when opening a new Window

    Patrick Olurotimi Ige, Dec 14, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    445
    Patrick Olurotimi Ige
    Dec 14, 2004
  2. Nacho Nachev

    How to handle form double submitting.

    Nacho Nachev, Apr 8, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    506
    Brock Allen
    Apr 8, 2005
  3. Sydex
    Replies:
    12
    Views:
    6,489
    Victor Bazarov
    Feb 17, 2005
  4. Todd Cary

    Opening a new window and not submitting

    Todd Cary, Jul 16, 2003, in forum: Javascript
    Replies:
    2
    Views:
    95
    Lasse Reichstein Nielsen
    Jul 17, 2003
  5. Display Name
    Replies:
    1
    Views:
    93
    Hywel Jenkins
    Oct 20, 2003
Loading...

Share This Page