0

I have a form that has form entries and submission confirmation on the same page. When submitted, currently the form entries remain when my submission message displays - so I wish to use Jquery to hide the form entries. My form has the the id of #mysubscription, can anyone spot why this form isn't clearing on submission?

<?php
        }

        if (isset($contact_form_submitted) && $contact_form_submitted) {
    ?>
        <p class="success"><strong><?php echo htmlspecialchars((isset($contact_form_message)) ? $contact_form_message : 'Submission successful.', ENT_QUOTES, 'utf-8'); ?></strong></p>
        <script type="text/javascript">jQuery('#mysubscription').hide()</script>

    <?php
        }
    ?>
2
  • use 'if (! isset($contact_form_submitted))' condition on your form Commented Oct 21, 2016 at 10:29
  • Can you share your entire code? It's hard to understand what you've done so far. Commented Oct 21, 2016 at 10:31

1 Answer 1

2

Try this

<!--You need to load library first without library $ wont work-->    
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <script type="text/javascript">
      /**
      * $(function(){}) is runs the script after DOM(document object model) loaded. this equivalent to ready() function. The ready() method specifies what happens when a ready event occurs.    
      */
       $(function(){ 
          $('#mysubscription').hide();
        });
    </script>
Sign up to request clarification or add additional context in comments.

1 Comment

You should also add an explanation why he should try this. It's good to have as a future reference...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.