/    Sign up×
Community /Pin to ProfileBookmark

Having trouble with this script, its almost done

I cant seem to get it to work. I need to create a menu, that allows for a submenu to show and hide when clicked. It also needs to switch the images onmouseover, as well as change the static image when clicked, the problem comes in when you change the static image and mouse is still over or mouses out, it switches back. Here is what I have so far:

[CODE]<script language=”JavaScript” type=”text/JavaScript”>

function switchImage(id)
{
if (lastSwitched){
lastSwitched.className=lastSwitched.className.replace(‘b’,”);
}
var men = document.getElementById(id);
var menclass = men.className;
men.className=menclass+’b’
lastSwitched = men;
}

function hoverMain(id)
{
var hovering = document.getElementById(id);
var hoverclass = hovering.className;
if (!hoverclass.match(/b$/))
{
hovering.className = hoverclass+’c’
}
}

funtion hoverOut(id)
(
var hovering = document.getElementByID(id);
var hoverclass = hovering.className;
if (!hoverclass.match(/b$/))
{
hovering.className = hoverclass.replace(/c/,”);
}
}

var last_expanded = ”;

function showHide(id)
{
var obj = document.getElementById(id);

var status = obj.className;

if (status == ‘hide’) {

if (last_expanded != ”) {
var last_obj = document.getElementById(last_expanded);
last_obj.className = ‘hide’;
}

obj.className = ‘show’;

last_expanded = id;
} else {
obj.className = ‘hide’;
}
}
</script>

<div><a id=”mainmenu2″ class=”rmenu2″ onclick=”showHide(‘rmymenu1’); switchImage(‘mainmenu2’)” onmouseover=”hoverMain(‘mainmenu2’)” onmouseout=”hoverOut(‘mainmenu2’)” border=”0″ target=”blockrandom” href=”index2.php?option=com_content&amp;view=article&amp;id=45″></a></div>[/CODE]

Thanks up front!

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @maltech 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.17,
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,
)...