/    Sign up×
Community /Pin to ProfileBookmark

Some Help Please

On my website, I have a glossary of terms in Japanese. Clicking on each term causes a dropdown which shows the English translation. I have a problem, however, once I click on the first term in the list, all of the following links end up changing color (as though the user has already clicked on them). How do I fix this problem.

My header script is
<script language=”javascript”>
<!–
var state = ‘none’;
function showhide(layer_ref) {
if (state == ‘block’) {
state = ‘none’;
}
else {
state = ‘block’;
}
if (document.all) { //IS IE 4 or 5 (or 6 beta)
eval( “document.all.” + layer_ref + “.style.display = state”);
}
if (document.layers) { //IS NETSCAPE 4 or below
document.layers[layer_ref].display = state;
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(layer_ref);
hza.style.display = state;
}
}
//–>
</script>

The body script is
<p><a href=”#” onclick=”showhide(‘div1’);”>show/hide me</a></p>
<div id=”div1″ style=”display: none;”>This is the content</div>
<p><a href=”#” onclick=”showhide(‘div2’);”>show/hide me</a></p>
<div id=”div2″ style=”display: none;”>This is the content</div>

Etc.

I look forward to any and all feedback.

Knuckle

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERJan 24.2008 — As a start, I would change as follows:
[code=php]
<script type="text/javascript">
function showhide(layer_ref) {
var state = document.getElementById(layer_ref).display;
if (state == 'block') { state = 'none'; }
else { state = 'block'; }
}
</script>
[/code]

and
[code=php]
<p><a href="#" onclick="showhide('div1');return false">show/hide me</a></p>
<div id="div1" style="display: none;">This is the content</div>
<p><a href="#" onclick="showhide('div2');return false">show/hide me</a></p>
<div id="div2" style="display: none;">This is the content</div>
[/code]


But more changes might be indicated depending on the rest of your code.
Copy linkTweet thisAlerts:
@KnuckledogauthorJan 24.2008 — Dear JMRKER

It still doesnt seem to work. Perhaps I am just dumb?
Copy linkTweet thisAlerts:
@JMRKERJan 24.2008 — Post your revised code please.
Copy linkTweet thisAlerts:
@JMRKERJan 25.2008 — Did you get it to work or just give up?
×

Success!

Help @Knuckledog 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.27,
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,
)...