Skip to content Skip to sidebar Skip to footer

Show Hidden Divs On Refresh

I'm having a very difficult time trying to figure out how to make my code function properly. I currently have a div that is hidden on load and changes once a selection is made from

Solution 1:

You can achieve this by just running showStates(this) on page load. Just add this to the bottom of your template:

:javascript
  window.onload = function() {
    select_location = document.getElementById('<id of select tag generated for location>')
    if(select_location[select_location.selectedIndex].value == 'United States')
    {
      document.getElementById('states_div').style.display = 'block';
    }
    else
    {
      document.getElementById('states_div').style.display = 'none';
    }
  };

Then if United States is present in the form it will display it.

Post a Comment for "Show Hidden Divs On Refresh"