title: Prevent button to page redirect in html
body: <p>I have a few buttons and a submit button. (Making simple) My idea is to receive the value of the clicked button using a php and display it <strong>only when submit</strong>. Here I face a problem that button click itself redirects to the page and displays the value (means it is not waiting for the submit button to press). I followed a javascript provided <a href="https://stackoverflow.com/questions/2635370/how-to-stop-page-redirect">here</a>. But didn’t work. Any method to achieve this? </p>
  
  <pre><code>&lt;form action="calculate.php" method="POST"&gt;
  
  &lt;button type="" name="btn" style="background-color:#7F77AE" value="Alf"&gt;x1&lt;/button&gt;
  &lt;button type="" name="btn" style="background-color:#7F77AE" value="ABI"&gt;y1&lt;/button&gt;
  &lt;button type="" name="btn" style="background-color:#7F77AE" value="APE"&gt;z1&lt;/button&gt;
  
  &lt;input type="submit" value="Submit"&gt;
  </code></pre>
  
  <p>php part is as simple as,</p>
  
  <pre><code> $button = $_POST['btn']; 
   echo $button;
  </code></pre>