/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Quick code/syntax question

Is there another way to write the line marked [B](*)[/B]?

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

var img0=new Image();
img0.src=”grnPNG.png”;

var img1=new Image();
img1.src=”orgPNG.png”;

var img2=new Image();
img2.src=”prpPNG.png”;

var img3=new Image();
img3.src=”file:redPNG.png”;

var h2text= [“Mean Green”, “Big Ol’ Orange”, “Big Purple Egg”, “Big Red Machine”];

function changeImgTxt(covers)

{

var index=covers.choice.selectedIndex;

document.getElementById(“theHed”).innerHTML=h2text[index];

[B](*)[/B]document.theImg.src = eval(“img”+ index +”.src”);

}
</script>

<html>
<head></head>

<body>

<h2 id=”theHed”>Mean Green</h2>

<img src=”grnPNG.png” name=”theImg” id=”theImg” alt=”ImageText”/>

<form id=”covers”>

<select name=”choice” onchange=”changeImgTxt(this.form)”>
<option>Big Green</option>
<option>Big Orange</option>
<option>Big Purple</option>
<option>Big Red</option>
</select>

</form>

</body>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@TheBearMayJun 24.2009 — document.getElementById("theImg").src="img"+ index +".src";
Copy linkTweet thisAlerts:
@13thwarriorauthorJun 24.2009 — The simple answers are always the ones that slip by. i appreciate the quick response.

Thanks...
×

Success!

Help @13thwarrior 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.16,
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,
)...