/    Sign up×
Community /Pin to ProfileBookmark

pass variable from onClick problem.

Hi

I’m using the following javascript to swap a whole bunch of images with an onClick link. the problem is the “sel” variable. it is set with the onClick like this:

[code=php]onClick=”bullet(L1);[/code]

but for some reason it’s not getting the varaible in the ‘Prop(sel,”,’src’,red,’IMG’);’ part of the script.

[code=php]
function Prop(objName,x,theProp,theValue) {
var obj = MM_findObj(objName);
if (obj && (theProp.indexOf(“style.”)==-1 || obj.style)){
if (theValue == true || theValue == false)
eval(“obj.”+theProp+”=”+theValue);
else eval(“obj.”+theProp+”='”+theValue+”‘”);
}
}
function bullet(sel){
var blue = ‘images/fmp_blue_bullet.jpg’;
var red = ‘images/fmp_red_bullet.jpg’;
Prop(‘L1′,”,’src’,blue,’IMG’);
Prop(‘L2′,”,’src’,blue,’IMG’);
Prop(‘L3′,”,’src’,blue,’IMG’);
Prop(‘L4′,”,’src’,blue,’IMG’);
Prop(‘L5′,”,’src’,blue,’IMG’);
Prop(‘L6′,”,’src’,blue,’IMG’);
Prop(‘L7′,”,’src’,blue,’IMG’);
Prop(‘L8′,”,’src’,blue,’IMG’);
Prop(‘L9′,”,’src’,blue,’IMG’);
Prop(‘L10′,”,’src’,blue,’IMG’);
Prop(sel,”,’src’,red,’IMG’);
}
[/code]

Any ideas anyone.

Chris

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@BillyRayAug 18.2004 — onClick="bullet(L1);[/quote]
Maybe because you're missing the closing quote from the above line?

Dan
Copy linkTweet thisAlerts:
@cybercampbellauthorAug 18.2004 — Sorry. that's a typo here. it's right in my script.

Any other ideas?

Cheers

Chris
Copy linkTweet thisAlerts:
@BillyRayAug 18.2004 — Maybe you can post the whole line with the "onclick" in it - minus typos, of course ?

Dan
Copy linkTweet thisAlerts:
@CharlesAug 18.2004 — If I understand your script, that should be:

[font=monospace]onclick="bullet('L1')"[/font]
Copy linkTweet thisAlerts:
@cybercampbellauthorAug 18.2004 — Sorted...Thanks.

It was onclick="bullet('L1')"

Thanks

Chris
×

Success!

Help @cybercampbell 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.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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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