/    Sign up×
Community /Pin to ProfileBookmark

I am doing rollovers that affect multiple images.

[INDENT]onMouseOver=”rollOver(‘navdottedbar’,’on’),rollOver(‘digi’,’on’)”

onMouseOut=”rollOver(‘digi’,’off’),rollOver(‘navdottedbar’,’off’)” [/INDENT]

I would like to do the same for an onClick event. This is what I have originally:

[INDENT]onClick=”rollOver(‘digi’,’on’,true); return false”[/INDENT]

How do I write it so that it affects two images or even three? Can I do this?

I tried:

[INDENT]onClick=”rollOver(‘digi’,’on’,true),rollOver(‘navi’,’on’,true); return false”

and

onClick=”rollOver(‘digi’,’on’,true), rollOver(‘navi’,’on’,true); return false”

and

onClick=”rollOver(‘digi’,’on’,true); return false,rollOver(‘navi’,’on’,true); return false”[/INDENT]

Nothing works. Can someone please tel me how to write this line. Thanks.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@FangSep 02.2005 — Why not put it all into 1 function and use the argument array to process the values:
onClick="rollOver('digi','navi','on',true)"
function rollOver() {
var arg=rollOver.arguments;
var argLen=arg.length;
var onOff=arg[argLen-2];
var bool=arg[argLen-1];
for(var i=0; i<argLen-2; i++) {
alert(arg[i]);
}
}
Copy linkTweet thisAlerts:
@s1deusauthorSep 04.2005 — Thx Fang, but is there a way to do this without altering the function? The code I have for the function rollOver is kinda long. If you are still willing to help I can post it or give you a link to the page.

Thanks,
Copy linkTweet thisAlerts:
@FangSep 04.2005 — Post what you've got.
Copy linkTweet thisAlerts:
@s1deusauthorSep 04.2005 — Thanks,

<SCRIPT LANGUAGE="JavaScript">

<!--

var iPath = 'images/';

var iExt = 'gif';

var loaded = false;

var suffix = new Array('up_on','dn_on','up_off','dn_off');

function preLoad()
{
if(document.images)
{
var argLen = arguments.length;
for(var i = 0; i < argLen; i++)
{
var arg = arguments[i];
var sufLen = suffix.length;
for(j = 0; j < sufLen; j++)
{
var suf = suffix[j];
iNew = arg + '_' + suf + ' = new Image();'; eval(iNew);
iSrc = arg + '_' + suf + '.src = '' + iPath + arg + '_' + suf + '.' + iExt + '';'; eval(iSrc);
}
}
loaded = true;
}
}

var clicked = '';

function rollOver(iName,state,click)
{
if(document.images)
{
if(click)
{
if(clicked != iName)
{
if(clicked != '')
{
document[iName].src = eval(iName + '_dn_' + state + '.src');
document[clicked].src = eval(clicked + '_up_off.src');
}
document[iName].src = eval(iName + '_dn_' + state + '.src');
clicked = iName;
}
}
if(clicked == iName)
{
document[iName].src = eval(iName + '_dn_' + state + '.src');
}
else
{
document[iName].src = eval(iName + '_up_' + state + '.src');
}
}
}

window.onLoad = preLoad('digi','navdottedbar','navspec','samp','navget','about','sales','awa');
// -->
</SCRIPT>



The HTML looks like this:

<A HREF="JavaScript://" onMouseOver="rollOver('navdottedbar','on'),rollOver('digi','on')" onMouseOut="rollOver('digi','off'),rollOver('navdottedbar','off')" onClick="rollOver('digi','on',true)"; return false" onFocus="this.blur()"><img src="images/digi_up_off.gif" name="digi" width="120" height="38" border="0"></a>


The concept is pretty simple. A nav with rollovers and when clicked, menu items remain in the rollover/highlighted state. Thing is each rollover/onclick affects two/three images hence my problem.

Thanks for your help. BTW, I did not write this code, I picked it up off another forum's thread.
×

Success!

Help @s1deus 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 4.30,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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