/    Sign up×
Community /Pin to ProfileBookmark

Problem with dropdown menu

Hey,

I am installing a vertical drop down menu on my website and everything is working perfect except for one little bug. I have about 12 links on my bar, two of them have children. When I load the page, the two sections with children are in a open state, which is not what I want. I want them to be closed on loading.

The odd part is, as soon as my mouse touches the menu, they instantly go to a closed state and then they work perfectly.

Here is my JS code.

[CODE]<script type=”text/javascript”>
<!–
window.onload=show;
function show(id) {
var d = document.getElementById(id);
for (var i = 1; i<=10; i++) {
if (document.getElementById(‘smenu’+i)) {document.getElementById(‘smenu’+i).style.display=’none’;}
}
if (d) {d.style.display=’block’;}
}
//–>
</script>[/CODE]

And here is my HTML code

[CODE] <dl id=”menu”>

<dt onclick=”javascript:show();”><a href=”index.html” class=”navigation_text”>Home</a></dt>
<dt onclick=”javascript:show();”><a href=”aboutus.html” class=”navigation_text”>About US</a></dt>
<dt onclick=”javascript:show(‘smenu2’);”><font class=”navigation_text”>Consulting</dt></font>
<dd id=”smenu2″>
<ul>
<li><a href=”operations.html” class=”navigation_text”>Operational</a></li>
<li><a href=”safety.html” class=”navigation_text”>Safety</a></li>
<li><a href=”internal.html” class=”navigation_text”>Internal</a></li>
</ul>
</dd>
<dt onclick=”javascript:show(‘smenu3’);”><font class=”navigation_text”>Driver Recruitment and Training</font></dt>
<dd id=”smenu3″>
<ul>
<li><a href=”premium.html” class=”navigation_text”>Premium</a></li>
<li><a href=”elite.html” class=”navigation_text”>Elite</a></li>
<li><a href=”standard.html” class=”navigation_text”>Standard</a></li>
</ul>
</dd>
<dt onclick=”javascript:show();”><a href=”dotsafe.html” class=”navigation_text”>DOT / Safety Compliance </a></dt>
<dt onclick=”javascript:show();”><a href=”fuel_mileage_tax.html” class=”navigation_text”>Fuel / Mileage Tax Service </a></dt>
<dt onclick=”javascript:show();”><a href=”licensing_permits.html” class=”navigation_text”>Licensing and Permits </a></dt>
<dt onclick=”javascript:show();”><a href=”traffictix.html” class=”navigation_text”>Traffic Tickets </a></dt>
<dt onclick=”javascript:show();”><a href=”drivers_wanted.html” class=”navigation_text”>Drivers Wanted </a></dt>
<dt onclick=”javascript:show();”><a href=”contact.html” class=”navigation_text”>Contact Us </a></dt>
<dt onclick=”javascript:show();”><a href=”sitemap.html” class=”navigation_text”>Site Map </a></dt>
</dl>[/CODE]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @teraric spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...