title: How to hide the one div on form submit and show another div?
body: <p>Below is my code. On button click I need submit the form and pass the value through post. Then the div <code>#con1</code> should get hidden and it should show the div <code>#con2</code>. In the div <code>#con2</code> I need to display the value which I get through post but the problem is on click the page keeps on reloading.
  downvoters kindly mention your comments </p>
  
  <pre><code>&lt;?php include("../view/common/head.php"); ?&gt;
  &lt;script&gt;
      $(document).ready(function() {
          $("#myform").submit(function() {
              $("#con1").hide();
              $("#con2").show();
          });
      });
  &lt;/script&gt;
  
  &lt;div class="container" id="con1"&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"&gt;
              &lt;form name="myform" class="form-horizontal" id="myform" method="post"&gt;
                  &lt;ul class="devices"&gt;
                      &lt;li&gt;
                          &lt;div class="dev-inner"&gt;
                              &lt;div class="dei-mid"&gt;&lt;p&gt;Computer Tower&lt;/p&gt;&lt;/div&gt;
                              &lt;div class="dei-rgt"&gt; 
                                  &lt;input type="text" class="form-control inpt-bx-txtclr-home" name="computername" id="computerid" placeholder="000"&gt;
                              &lt;/div&gt;                  
                          &lt;/div&gt;
                      &lt;/li&gt;
                  &lt;/ul&gt;
                  &lt;button type="submit" id="grad-btn"&gt;Calculate&lt;/button&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="container" id="con2" style="display:none"&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"&gt;
              &lt;p&gt;&lt;?php echo $_POST['computername'];?&gt;&lt;/p&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>