/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Javascript (onclick) pop up bigger image window from image array

I have an array of images that populate the page. I want the user to click on an image and a bigger version of the same image is supposed to appear in a popup-window coded as such: onclick=”window.open(‘http://your.domain.com + this.src)”>

This works for the first image but since I have them grouped in arrays as cover, coverone and covertwo, the code does not work for each image (under the cover array and under coverone array and so on). Anyway to go about it?

here is the js code:

var str = “<table>”;
var imgFolder = “images/”;

var cover = new Array();
cover[0] = “kitchenHouseSale.jpg”;
cover[1] = “eatLive.jpg”;
cover[2] = “loveAnthonySale.jpg”;

var coverone = new Array();
coverone[0] = “casualVacancy.jpg”;
coverone[1] = “quiet.jpg”;
coverone[2] = “whirlAway.jpg”;

var covertwo = new Array();
covertwo[0] = “everyLastSale.jpg”;
covertwo[1] = “neilYoung.jpg”;
covertwo[2] = “soupSisters.jpg”;

for (var i = 0; i < cover.length; i++)
{
str += “<tr><td colspan=’2′><h2>” + category[i] + “</h2></td></tr>”;
str += “<tr><td class=’basket’><img src='” + imgFolder + cover[i] + “‘ width=’108′ height=’159’ onclick=”open_win()”>
}

str += “</table>”;
var elem = document.getElementById(“table”);
elem.innerHTML = str;

Any help is appreciated. Thanks!

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @marelda 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.21,
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,
)...