Keep div shown after submitting form using jQuery in MODx Evo

54 Views Asked by At

I have a form that is hidden when first loading this page

Once user clicks the chevron down below "CONTACT US AND TELL US ABOUT YOUR CASE" the form appears.

Once eform submits, the form becomes hidden again

<div class="describe" style="display: none;">

and validation messages are not viewable unless the chevron is clicked again as seen here:

https://share.getcloudapp.com/RBuXmEvE

I'm using

<button type="button" value="Submit" onclick="this.form.submit();">Submit</button>

to submit the form.

Should I call another javascript function that runs onclick as well as the code to display the form?

I believe that the javascript code currently being used to show and hide the form is here:

<script>
$(document).ready(function(){

          $('.case > a').click(function(){
           $('.describe').slideToggle();  
              $(this).toggleClass('active');
          });

     });    
  </script>

Or should I attempt to show the form in a MODx snippet (which is just PHP code)?

1

There are 1 best solutions below

0
Joshua Lückers On

You can use a snippet to determine if the form is submitted and use that result to display (or not) your element. I suggest using an Extra named FormIt for creating forms on your website (FormIt documentation).