/    Sign up×
Community /Pin to ProfileBookmark

javascript in css menu driven by dynamic php

I’m not seasoned JS coder and I have come across this problem.

I appreciate if you show me what is not right with what I do:
—————————————————————


case: css driven menu (based on suckerfish menu: [url]http://www.htmldog.com/articles/suckerfish/dropdowns/example/bones3.html[/url])
—————————————————————

Since IE does not support p-class hover, java script is used:

[CODE]sfHover = function() {
var sfEls = document.getElementById(“nav”).getElementsByTagName(“LI”);
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=” sfhover”;
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(” sfhover\b”), “”);
}
}
}
if (window.attachEvent) window.attachEvent(“onload”, sfHover);
[/CODE]

I try to dynamically access database using php to populate menu as needed (while loop).

PROBLEM:
JavaScript responsible for :hover replacement for IE does not work inside of php loop.
It displays only first set of hover elements.

Any thoughts?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@jasonahouleNov 06.2008 — try

this.className = this.className.replace(/sfhover/, '');
Copy linkTweet thisAlerts:
@jeff7691authorNov 06.2008 — I was to "loop greedy" and I did include external "ul" inside of a loop.

That messed up everything.

Sorry for taking time.

Regards,

Jeff
×

Success!

Help @jeff7691 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 5.20,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...