title: How to toggle show and hide for two forms present in the same div?
body: <p>I have two forms present in a div, form1 is visible when the page loads, and if I click the next button form1 is hidden and form2 is shown, which is working as expected. </p>
  
  <p>Now I want to achieve the reverse of above scenario which is on click of a back button, form2 should be hidden and form 1 is shown. </p>
  
  <p>Here's javascript code I have so far..</p>
  
  <pre><code>function switchVisible() {
  
    document.getElementById("disappear").innerHTML = "";
  
    if (document.getElementById('newpost')) {
  
      if (document.getElementById('newpost').style.display == 'none') {
        document.getElementById('newpost').style.display = 'block';
        document.getElementById('newpost2').style.display = 'none';
      } else {
        document.getElementById('newpost').style.display = 'none';
        document.getElementById('newpost2').style.display = 'block';
      }
  
    }
  
  }
  </code></pre>
  
  <p>So basically I am looking for a way to achieve toggle functionality for two forms present in the same div using javascript and setting their display property.</p>