/    Sign up×
Community /Pin to ProfileBookmark

Right…here’s the thing. I want to populate an array with id’s belonging to the images here, and then manipulate them using the array, I know it’s possible, but how do I do it? This is the furthest I’ve come so far….please help

imarr=new Array;
for (i=1; i<=5; i=i+1)
{ imarr[i]= ‘imvar’ + i };

imgindex = 2
imarr[imgindex].width= 200

<IMG ID=imvar1 SRC=”katt.jpg”>
<IMG ID=imvar2 SRC=”katt.jpg”>
<IMG ID=imvar3 SRC=”katt.jpg”>
<IMG ID=imvar4 SRC=”katt.jpg”>
<IMG ID=imvar5 SRC=”katt.jpg”>

I think you get the general idea of what i wanna do here…but where does it go wrong?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterNov 22.2005 — <i>
</i>for (i=1; i&lt;=5; i=i+1)
{ imarr[i]=[color=blue]document.getElementById( 'imvar' + i)[/color] };

Also make sure to execute the JavaScript during the onload event handler so that the IMGs exist at the time you try to access them.
×

Success!

Help @Destruantes 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.28,
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,
)...