Results 1 to 5 of 5

Thread: Form animation on submit

  1. #1
    Join Date
    Jul 2011
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Form animation on submit

    Hello all, I'm looking for that javascript that displays
    an animation in a lightbox or a new page that says "Form
    processing...do not refresh" or similar effect after the submit button has
    been clicked.

    Thanks.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Are you looking only for the visual effect of this, or do you need some extra functionality attached to it?
    You should be able to use onsubmit for the form and trigger a Javascript function that will launch a lightbox window.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jul 2011
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks. Visual effect.

    Is there some existing script that can do this?

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Here's a rough version that you can adjust as needed:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" dir="ltr">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Submitted Form</title>
    <script type="text/javascript">
    function submitted() {
    	document.getElementById('submitteddisplay').style.display = 'block';
    }
    </script>
    <style type="text/css">
    div#submitteddisplay { display:none; }
    div#submittedbg { position:fixed; width:100%; height:100%; background-color:gray; opacity:0.5; }
    div#submitted { margin:auto; position:fixed; margin-top:40%; width:100%; }
    div#submitted div { border:10px solid black; width:50%; margin:auto; background-color:white; text-align:center;}
    </style>
    </head>
    <body>
    
    <div id="submitteddisplay">
    <div id="submittedbg"></div>
    <div id="submitted">
    	<div>
    		<p>Submitted. Please wait.</p>
    	</div>
    </div>
    </div>
    
    
    <form onsubmit="submitted();" method="post" action="?">
    	<input type="submit" />
    </form>
    
    </body>
    </html>
    Use onsubmit="submitted();" on any form you'd like and it will bring up the message hiding the rest of the page. You can remove the background part if you'd like but this way it actually doesn't allow the user to resubmit the form because it is hidden.

    Note that you need to copy the CSS and the Javascript from the head section to the head section of your page. And you need to copy the "submitted" divs from the start of the body section, and these must be placed outside any of the rest of your body content. It's best to place them either at the beginning or end of your page, away from your content. Then just add the onsubmit attribute to your form.

    Is that close to what you wanted? You can change the content of the innermost div to anything you'd like, including an image or text.


    By the way, using the same method you can apply this to any "lightbox" script you'd like. Just use onsubmit="lightboxfunction();" as above and find a lightbox that will allow Javascript activation. (There are many. The only ones that don't do it are those that are set to work only for images.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. The Following User Says Thank You to djr33 For This Useful Post:

    tim2011 (07-26-2011)

  6. #5
    Join Date
    Jul 2011
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks a lot

Bookmarks

Posting Permissions

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