Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Location
    Pennsylvania, United States
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Thank You popup after Submission of Form

    Hey there.

    I'm looking to figure out a simple operation here, but getting stuck in the process. I have about... zero knowledge of the language this would be done in. I have a form (http://www.bucketbux.com/referralspam.php) where I would like a popup to appear once the submission of the form has been completed.

    Here is what I have thus far:

    PHP Code:
    <script language="javascript" type="text/javascript">
        function 
    vaidation()
        {
            var 
    form document.refspam;
            
            if (
    form.ref_link.value == '' || form.email.value == '')
            {
                
    alert ('Please fill out the form completely before clicking submit!');
                return 
    false;
            }
            
            return 
    true;
        }    
    </script> 
    If you notice, a window will appear if the form has not been filled out completely. I'm just not sure how to do what is, essentially the opposite. :P

    Help is appreciated! Thank you. =]

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    Surely function vaidation() should be function validation()

    To create a pop-up, place the following right before return true;

    var popWin = "";
    function openwin(url, strWidth, strHeight) {
    if (popWin != "") {popWin.close()}
    leftStr = (screen.width-strWidth)/2;
    topStr = (screen.height-strHeight)/2-50;
    windowProperties = "toolbar=no,menubar=no,scrollbars=no,statusbar=no,height="+strHeight+",width="+strWidth+",left="+lef tStr+",top="+topStr+"";
    popWin = window.open(url,'newWin',windowProperties);
    }
    openwin('yourUrl.html',400,500);


    Where the page yourURL.html contains the text of the message. Obviously you can change the size of the window to suit.


    You asked for a pop-up. Be aware that many browsers block pop-up windows these days. Or do you mean just a simple alert?

    If so, right before return true add:-

    alert ("Thank you for submitting the form");




    He thought he saw a Rattlesnake
    That questioned him in Greek:
    He looked again, and found it was
    The Middle of Next Week.
    "The one thing I regret," he said,
    "Is that it cannot speak!"
    - Lewis Carroll
    Last edited by Philip M; 03-04-2009 at 08:48 AM.

  • Users who have thanked Philip M for this post:

    Kovich (03-04-2009)

  • #3
    New to the CF scene
    Join Date
    Mar 2009
    Location
    Pennsylvania, United States
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Unbelievable. I can't believe I didn't figure that out...

    (Yes, by the way - it was the alert I was looking for.)

    The same piece of code was used right before return false! Well, the simplest things are often the easiest to mess up, right?

    Also, thanks for catching the validation typo. I did notice that after posting this thread but didn't think of editing it here. =]

    Well, I tested the page and the alert works properly. Thank you very much!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •