title: Remember HTML dropdown value if registration page reloads
body: <p>I have a WordPress page where the default login/signup page is disabled and I let users register via a WooCommerce login/signup page with a bunch of custom fields added through my theme's functions.php.</p>
  
  <p>One of those fields is a dropdown field that lets users select their country.</p>
  
  <p>If a user misses something in the registration form and the page reloads (with an error message telling the user what was missing), the text fields are pre-populated with their previous text. The dropdown menu, however, reverts back to its neutral option instead of remembering its previous value.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>&lt;?php add_filter( 'woocommerce_register_form', 'adding_custom_registration_fields' );
  function adding_custom_registration_fields($fields) {
  $countries_obj = new WC_Countries();
  $countries = $countries_obj-&gt;__get('countries'); ?&gt;
  
  &lt;div class="form-row form-row-wide"&gt;
      &lt;label for="reg_billing_country"&gt;&lt;?php _e( 'Country', 'woocommerce' ); ?&gt; &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
      &lt;select class="country_select sk-required" data-sk-tooltip="Required" name="billing_country" id="reg_billing_country"&gt;
          &lt;option value=""&gt; &lt;?php _e('Select country','my-theme'); ?&gt;&lt;/option&gt;
          &lt;?php foreach ($countries as $key =&gt; $value): ?&gt;
              &lt;option value="&lt;?php echo $key?&gt;"&gt;&lt;?php echo $value?&gt;&lt;/option&gt;
          &lt;?php endforeach; ?&gt;
      &lt;/select&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I want the dropdown field to remember its value if the page reloads, just like the text fields do. Can I use html to encourage the browser to cache the value? </p>
  
  <p>I tried </p>
  
  <pre><code>var selectedItem = sessionStorage.getItem("country_select_session"); 
  $('#reg_billing_country').val(selectedItem); 
  $('#reg_billing_country').change(function() { 
    var dropVal = $(this).val(); 
    sessionStorage.setItem("country_select_session", dropVal); 
  }); 
  </code></pre>
  
  <p>However, the value is only retained if I manually reload the page using F5. If the page reloads by clicking the "submit" button with an incomplete form, the dropdown menu reverts back to its default value, ignoring the script</p>