www.webdeveloper.com
Results 1 to 3 of 3

Thread: Contact form popup window

  1. #1
    Join Date
    Jun 2013
    Posts
    2

    Contact form popup window

    Hi All,
    I have to say this is my first time ever on a forum, well except from the beginning days when I hosted a BBS on my Apple IIe, anybody remember that?
    Anyway, I hope somebody can help. I am looking for some javascript code that will make my contact.php form popup in the same window with a transparent background, just like you see on most of the high-end popular web sites.
    I have the form made with the help of some software, but I would like for it to popup just like latest stuff you see out there.
    Can anyone Help?
    Thanks,
    Brad_35

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    take it as a draft:

    index.php

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>The index page</title>
    <style type="text/css">
    body{color:#777;background-color:#fff;font-family:'Bookman Old Style',Georgia,Verdana;font-size:14px;text-align:center;font-weight:bold;padding-top:250px;}
    a:link,a:active,a:visited{text-decoration:none;font-weight:bold;background-color:transparent;color:#000;font-family:Georgia,Verdana;font-size:16px;}
    a:hover{text-decoration:none;font-weight:bold;background-color:transparent;color:Crimson;}
    #result{position:absolute;text-align:center;display:none;border:1px solid #ccc;border-radius:25px;background-color:#F3F5FF;padding:100px 100px;opacity:.9;}
    .btn{border:none;cursor:pointer;background-color:transparent;color:Salmon;font-weight:bold;font-size:16px;}
    </style>
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script type="text/javascript" src="script.js"></script>
    </head>
    <body>
    <h2>bla-bla-bla</h2>
    <div>...feel free contacting us via <a id="contactus" href="#null">Contact form</a></div>
    <div id="result"></div>
    </body>
    </html>
    contact.php

    Code:
    <?php
    function showForm(){
    echo '<form name="mf" id="mf" action="" method="post">
    <h2>This is<br />my super-pooper form<br />made with the help of some software</h2>
    <input type="button" class="btn" id="snd" value="[ Send it to Fidel Castro ]" />
    </form>';
    }
    
    function sndForm(){
    /* here goes checking data and so on...
    then sending
    if everything's good and sending done 
    show message to the user
    */
    echo '<h3>Everything\'s cool.<br /><br />Viva Cuba!</h3><script type="text/javascript">setTimeout(\'$("#result").fadeOut("fast")\',3000);</script>';
    }
    
    /*---------------------------------------------------------------------*/
    $mode=(!empty($_GET['mode']))?$_GET['mode']:$_POST['mode'];
    switch($mode){
    case 'snd': sndForm();break;
    default: showForm();break;
    }
    ?>
    script.js

    Code:
    function findCenter(obj){
    var deltaX=parseInt(obj.css('padding-left')),deltaY=parseInt(obj.css('padding-top'));
    obj.css('left',$(window).width()/2-obj.width()/2-deltaX+'px').css('top',$(window).height()/2-obj.height()/2-deltaY+'px');
    }
    
    $(document).ready(function(){
    $('#contactus').click(function(){
    $('#result').html('<h3>Loading</h3>').css('display','block');findCenter($('#result'));
    $.get('contact.php',function(data){
    $('#result').html(data);findCenter($('#result'));
    $('#snd').click(function(){
    $('#result').append('<br /><br /><div><i>Sending...</i></div>');
    $.post('contact.php',{mode:'snd',formfield1:'value1',formfield2:'value2',formfield3:'value3'},function(data){$('#result').html(data);findCenter($('#result'));});
    });
    });
    });
    });
    live demo
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Jun 2013
    Posts
    2
    Thank you very much! that helps out alot

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles