/    Sign up×
Community /Pin to ProfileBookmark

Trying to do a simple image swap , but i have to do this with 48 buttons (for half hour inrements in a day, and there might be several days)… i’m trying to get this to work with 1 function. I could brute force a function for everyday … but i don’t obviously want to do that.

heres a small sample

<head>
<script type=”text/javascript”>

var1 =”buttons/100a_off.bmp”;
var2 =”buttons/100a_on.bmp”;

var26 = “IMG1”;
var27 = “IMG2”;

function swapImage(txt1,txt2,counter,picSource) {

switch (counter) {
case 1:
alert(txt1);
picSource.src = txt1
counter = 2
return counter;
case 2:
alert(txt2);
picSource.src = txt2
counter = 1
return counter;
}
}

</script>
</head>

<body>

<IMG id=var26 name=”IMG1″ src=”buttons/100a_off.bmp”
onclick=”intImage1 = swapImage(var1,var2, intImage1, var26);”>

<IMG id=var27 name=”IMG2″ src=”buttons/130a_off.bmp”
onclick=”intImage2 = swapImage(var3,var4,intImage2, var27);”>

</body>

It’s so simple and the first button works, the second butter turn’s “On” or is highlighted ( which is the swap.. ) but it won’t turn off.. even though the alert shows that it is being accessed and the correct location is being passed in.

Thanks for any help

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@naffets77authorJun 08.2006 — figured it out.. i put a zero instead of an 0, and copy pasted it a bunch. WHy is the 0 and the O right next to each other???
×

Success!

Help @naffets77 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.24,
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,
)...