Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I found this fancy popup form, which I would like to use in my page. I cannot understand well how can I remove the link 'click to open' and open the form immediately once my page loads.

XML
<body>

        <div id="wrapper">
            <p><a class="modalbox" href="#inline">click to open</a></p>
        </div>

        <!-- hidden inline form -->
        <div id="inline">
            <h2>Administration</h2>

            <form id="contact" name="contact" action="#" method="POST">
                <label for="username">User: </label>
                <input type="username" id="username" name="username" class="txt"> <!-- using style.css -->
                <br>
                <label for="password">Password</label>
                <input type="password" id="password" name="password" class="txt"> <!-- using style.css -->
                <br>
                <button id="send">Login</button>
                <!--<input type="submit" value="Login">-->
            </form>
        </div>

        <!-- basic fancybox setup -->
<script type="text/javascript">

    $(document).ready(function() {
        $(".modalbox").fancybox();
        $("#contact").submit(function() { return false; });


        $("#send").on("click", function(){

            var username    = $("#username").val();
            var password    = $("#password").val();

         {
                // first we hide the submit btn so the user doesnt click twice
                $("#send").replaceWith("<em>logging in...</em>");

                $.ajax({
                    type: 'POST',
                    url: 'pc_mainloginexec.php',
                    data: $("#contact").serialize(),
                    success: function(data) {

                            $("#contact").fadeOut("fast", function(){
                            if (data != 'false') {
                                $(this).before("<p><strong>Success!</strong></p>");
                                setTimeout("$.fancybox.close()", 1000);
                                //alert(data);
                                location.replace("http://my-url.com/admin.php");
                                }
                            });
                    }
                });
            }
        });
    });
</script>
</body>
Posted
Updated 31-Dec-13 3:38am
v2
Comments
I can't see any link with name "click to open". There is only one Login button.
datt265 31-Dec-13 11:37am    
it is in the first <div>
Oh yes, my mistake. Anyway, you problem is solved by Solution 2.

So, happy coding. Happy new year. :)

Make click to open hidden and Try using
JavaScript
$(".modalbox").fancybox().trigger('click');
instead of
JavaScript
$(".modalbox").fancybox();
 
Share this answer
 
XML
<script>
;(function($) {
    $(window).load(function(){
        $('#popup').bPopup({
        easing: 'easeOutBack',
        speed: 450,
        transition: 'slideDown'
        });
    });
})(jQuery);
</script>

**************

<div id="popup">
stuff
</div>


There are some nice dress up effects the popup can have here:

bpopup

I've included some effects in the example onload code.

Terry
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900