Fire event on pag refresh

Fire event on pag refresh

Hello,

I have this code:

  1.  <script>
    $(document).ready(function(){
        $('#country_choice').on('change', function() {
          if ( this.value == '138')
          {
            $("#town_dropdown").show();
            $("#town_input").hide();
          }
          else
          {
            $("#town_input").show();
            $("#town_dropdown").hide();
          }
        });
    });
    </script>


It works very well when you select the dropdown menu with the id "country_choice" but my problem comes when I submit my form and there is an error, I have(with php) used the $_POST to get the id and name of the country in that dropdown, that's all good but jqeury does not automatically show again the "town_dropdown" when the id is equal to the currently 138.


I tried to add multiple events but none of them work:

  1.  <script>
    $(document).ready(function(){
        $('#country_choice').on('change load ready, function() {
          if ( this.value == '138')
          {
            $("#town_dropdown").show();
            $("#town_input").hide();
          }
          else
          {
            $("#town_input").show();
            $("#town_dropdown").hide();
          }
        });
    });
    </script>

Any idea why please?

Thanks