telo78
telo78

Reputation: 131

How to close fancybox on submit...Need help please

I really need this pop up box (fancybox) to close when a user submits the form... Right now, it is redirecting to the same form (signup.php) after 2 seconds but I wanted it to say the thank you message then closes the box...

<h1>SIGN UP</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>

<?php if($form_complete === FALSE): ?>

<div id="newsletter">

    <!-- <div  id="fancybox-close1"><a href="#" onClick="parent.jQuery.fancybox.close();"><img src="js/fancybox/fancy_close.png" /></a></div> -->

    <form id="form" name="form" method="post" action="signup.php">
    <label></label>
        <fieldset>
            <label>Name: <?php if(in_array('name', $validation)): ?><span class="error"><?php echo $error_messages['name']; ?></span><?php endif; ?><input type="text" id="name" name="name" value="<?php echo isset($_POST['name'])? $_POST['name'] : ''; ?>" onFocus="this.value=''" maxlength="255"></label>

            <label>Surname: <?php if(in_array('name', $validation)): ?><span class="error"><?php echo $error_messages['surname']; ?></span><?php endif; ?><input type="text" id="surname" name="surname" value="<?php echo isset($_POST['surname'])? $_POST['surname'] : ''; ?>" onFocus="this.value=''" maxlength="255"></label>

            <label>Position: <?php if(in_array('name', $validation)): ?><span class="error"><?php echo $error_messages['position']; ?></span><?php endif; ?><input type="text" id="position" name="position" value="<?php echo isset($_POST['position'])? $_POST['position'] : ''; ?>" onFocus="this.value=''" maxlength="255"></label>

            <label>Organization: <?php if(in_array('name', $validation)): ?><span class="error"><?php echo $error_messages['organization']; ?></span><?php endif; ?><input type="text" id="organization" name="organization" value="<?php echo isset($_POST['organization'])? $_POST['organization'] : ''; ?>" onFocus="this.value=''" maxlength="255"></label>

            <label>Email: <?php if(in_array('email', $validation)): ?><span class="error"><?php echo $error_messages['email']; ?></span><?php endif; ?><input type="text" id="email" name="email" value="<?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" onFocus="this.value=''" maxlength="255"></label>
            <input type="submit" id="submit" name="submit" value="SIGN-UP">
        </fieldset>
    </form><!-- end sign up form -->

    <?php else: ?>
        <div class="thankyouMessage">Thank you for subscribing!</div>
            <script type="text/javascript">
            setTimeout('ourRedirect()',2000)
            function ourRedirect(){
                location.href='signup.php'
            }
        </script>
    <?php endif; ?>

Upvotes: 1

Views: 4782

Answers (1)

Pablo Martinez
Pablo Martinez

Reputation: 2182

you can use:

<script type="text/javascript">
    parent.$.fancybox.close();
</script>

in the pop up box to close fancybox.

(if this don't close the pop up include jquery and fancybox libraries in the pop up)

Upvotes: 3

Related Questions