troubleshooting Question

Need DIV hidden on page load

Avatar of fjkilken
fjkilken asked on
JavaScript
2 Comments1 Solution637 ViewsLast Modified:
HI, I have some code (below) which works perfectly to show/hide a DIV, the only issue is that the DIV is visible when the page is loaded, clicking the button unhides the DIV.
I would like the opposite:
I want the DIV hidden when someone visits the webpage, then when they click the button I want the DIV to be visible - thanks

<script language="JavaScript">
      function toggle(id) {
            var state = document.getElementById(id).style.display;
            if (state == 'none') {
                  document.getElementById(id).style.display = 'block';
            } else {
                  document.getElementById(id).style.display = 'none';
            }
      }
</script>


 <input name="btn_show_dir_map" type="button" value="Click to show directions map"
                         onclick=" toggle('race_directions_map'); return false"/>
<DIV ID="race_directions_map" NAME="race_directions_map">
<IFRAME ID="iframe_race_directions_map" CLASS="InlineBdr" WIDTH="800" HEIGHT="600" BORDER="0" FRAMEBORDER="no"
                                    src="http://maps.google.com/maps?saddr=newry,+co.down&daddr=53.1554634861,-6.18778650738+(%22Djouce+Wood+carpark%22)&ie=UTF8&v=2.2&cv=4.2.0198.2451&hl=en&ll=53.666745,-6.285015&spn=1.493813,2.504883&z=8" style="color:#0000FF;text-align:left">
                              </IFRAME>
                        </DIV>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros