title: Retaining dropdown values after submitting form using GET method
body: <p>I am using dropdown to select values, and after I click the submit button, my values change. Please help me retain the selected values. Using POST method I have got the solution, but I want to use with GET method. Is it possible?</p>
  
  <p>1.) 1st select stmt:</p>
  
  <pre><code>&lt;form action="" method="GET"&gt;
     &lt;select name="sort"  &gt;
       &lt;option value="inc_patientName"&gt;Patient Name&lt;/option&gt;
       &lt;option value="inc_date"&gt;Date&lt;/option&gt;
       &lt;option value="inc_status"&gt;Status&lt;/option&gt;
       &lt;option value="inc_patientAge"&gt;Age&lt;/option&gt;
     &lt;/select&gt;
     &lt;input type="submit" name="GETREPORT" value="Get Report"/&gt;
     if ($_GET)
     {echo"hi";}
  &lt;/form&gt;
  </code></pre>
  
  <p>2.) 2nd select with while</p>
  
  <pre><code>&lt;?php
      //Selecting ward from table ward master
      $sql = "SELECT ward_name,ward_id FROM ward_master";
      $result = mysql_query($sql);
      echo "&lt;select name='ward'&gt;";
      while ($row = mysql_fetch_array($result)) 
      {
      echo "&lt;option value='" . $row['ward_id'] . "'&gt;" . $row['ward_name'] . "&lt;/option&gt;";
      }
      echo "&lt;/select&gt;";
      ?&gt;
  </code></pre>
  
  <p>3.) 3rd select with javascript:</p>
  
  <pre><code>&lt;select name="daydropdown" id="daydropdown" &gt;&lt;/select&gt; 
      &lt;select name="monthdropdown" id="monthdropdown"&gt;&lt;/select&gt;
      &lt;select name="yeardropdown" id="yeardropdown"&gt;&lt;/select&gt;
      &lt;script type="text/javascript"&gt;
      populatedropdown("daydropdown", "monthdropdown", "yeardropdown")
  </code></pre>
  
  <p>Javascript code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var monthtext=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];
  function populatedropdown(dayfield, monthfield, yearfield)
  {
     var today=new Date()
     var dayfield=document.getElementById(dayfield)
     var monthfield=document.getElementById(monthfield)
     var yearfield=document.getElementById(yearfield)
     for (var i=1; i&lt;=31; i++)
     dayfield.options[i]=new Option(i, i)
     dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today's day
     for (var m=0; m&lt;12; m++)
     monthfield.options[m]=new Option(monthtext[m], monthtext[m])
     monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true) //select today's month
     var thisyear=1999
     for (var y=0; y&lt;45; y++){
     yearfield.options[y]=new Option(thisyear, thisyear)
     thisyear+=1
     }
     yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
  }    
  &lt;/script&gt;
  </code></pre>