title: How to store previous selection in drop down menu in this case in html/php
body: <p>I have drop down on change I have set a confirmation, clicking OK the form is submitted this part is working fine but on clicking cancel the selection still changes in drop down how do I prevent that. </p>
  
  <p>How do I store my previous selection and set that when I click cancel to drop down?</p>
  
  <pre><code>&lt;td style="width:auto;text-align:center"&gt;
  &lt;select class="form-control" name="Ostatus" onchange="if(confirm('Are you sure you want change the status?')){this.form.submit()}"&gt;                    
  &lt;option value="Uploaded" &lt;?php if ($dispatchstatus == "Uploaded") echo "selected='selected'";?&gt; &gt;Uploaded&lt;/option&gt;
  &lt;option value="Processing" &lt;?php if ($dispatchstatus == "Processing") echo "selected='selected'";?&gt; &gt;Processing&lt;/option&gt;
  &lt;option value="Dispatched" &lt;?php if ($dispatchstatus == "Dispatched") echo "selected='selected'";?&gt; &gt;Dispatched&lt;/option&gt;
  &lt;/select&gt;
  &lt;/td&gt;
  </code></pre>