Note that there are some explanatory texts on larger screens.

plurals
  1. POHIde form elements when page initially loads
    text
    copied!<p>HI I have a drop down menu, which determins which sections of a form should be displayed. This works, except for when the initial page loads all of the elements are shown. Once you make a selection it then displays only the correct elements.</p> <p>Below is my Javascript, is there a way to set all of the elements to hidden initially, sorry if this is a stupid question but i am new to javascript.</p> <pre><code>if (current_value == "page_name") { document.getElementById("contains").style.display = "block"; document.getElementById("term").style.display = "block"; document.getElementById("countries").style.display = "none"; document.getElementById("postcodes").style.display = "none"; document.getElementById("repeater").style.display = "none"; document.getElementById("visitor_type").style.display = "none"; document.getElementById("page_visits").style.display = "none"; document.getElementById("pvisits_value").style.display = "none"; } else if (current_value == "postcode") { document.getElementById("contains").style.display = "none"; document.getElementById("term").style.display = "none"; document.getElementById("countries").style.display = "none"; document.getElementById("postcodes").style.display = "block"; document.getElementById("repeater").style.display = "none"; document.getElementById("visitor_type").style.display = "none"; document.getElementById("page_visits").style.display = "none"; document.getElementById("pvisits_value").style.display = "none"; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload