title: Keep the dropdown values after submit the form
body: <p>Creating dropdown box dynamically and options are adding through javascript arrays and I wanted to keep the values after i submit the form. Let us say if I select 'OOR' and '2' then after submit the form, I wanted to see these values in those dropdowns. </p>
  
  <p>Thanks.</p>
  
  <pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;script language="javascript"&gt;
  
      OORs=new Array("1","2","3","4");
      NoOORs=new Array("A","B","C");
  
      populateSelect();
      $(function() {
  
  
          $('#fenv').change(function(){
              populateSelect();
          });
  
      });
      function populateSelect(){
  
          fenv=$('#fenv').val();
  
          $('#market').html('');
          if(fenv=='OOR'){
              $.each(OORs,function(index,t) {
                  $("#market").append("&lt;option value='"+t+"'&gt;" +t+ "&lt;/option&gt;");
              });
          }
          else {
              $.each(NoOORs,function(index,t) {
                  $("#market").append("&lt;option value='"+t+"'&gt;" +t+ "&lt;/option&gt;");
              });
  
          }
  
      }
  &lt;/script&gt;
  
  &lt;form&gt;
      &lt;select id="fenv" NAME="fenv"&gt;
          &lt;option value="OOR2"&gt;OOR2&lt;/option&gt;
          &lt;option value="OOR"&gt;OOR&lt;/option&gt;
  
      &lt;/select&gt;
  
      &lt;select id="market" name="market"&gt;&lt;/select&gt;
      &lt;input type="submit" name="submit" value="submit"  &gt;
  &lt;/form&gt;
  </code></pre>