tomwaits4noman
04-11-2009, 05:37 PM
Hello
looking to create a gallery using javascript that supports all img formats
below is the code I have so far. would love some help with this. thanks in advance
<html>
<head>
<title>Template</title>
<script>
function picObj(idNum, w, h, altText) {
this.idNum = idNum;
this.width = w;
this.height = h;
this.alt = altText;
}
function picGalleryObj(c, fldr, imgNameFormat, pixArr) {
this.cur_pos = c;
this.folder = fldr;
this.format = imgNameFormat;
this.pix_array = pixArr;
this.move = move;
this.draw = draw;
}
myPix = new Array();
myPix[0] = new picObj('001', 300, 400, image description!!');
myPix[1] = new picObj('002', 300, 400, image description!!');
myPix[2] = new picObj('003', 300, 400, image description!!');
myPix[3] = new picObj('004', 300, 400, image description!!');
myPix[4] = new picObj('005', 300, 400, 'Help Iz!!');
myPix[5] = new picObj('006', 300, 400, image description!!');
myPix[6] = new picObj('007', 300, 400, image description!!');
myPix[7] = new picObj('008', 300, 400, image description!!');
var myGallery = new picGalleryObj(1, 'pix', 'Picture ', myPix);
function move(pos, div_id) {
this.cur_pos += pos;
if(this.cur_pos < 1) {
this.cur_pos = this.pix_array.length;
}
if(this.cur_pos > this.pix_array.length) {
this.cur_pos = 1;
}
draw(div_id);
}
function draw(div_id) {
the_string = "";
the_string += "<img src='" + this.folder + "/" + this.format + " + this.cur_pos + ".jpg' alt='" + this.pix_array[this.cur_pos].alt + "' width='" + this.pix_array[this.cur_pos].width + "' height='" + this.pix_array[this.cur_pos].height + "' />";
document.getElementById(div_id).innerHTML = the_string;
}
</script>
<link rel="stylesheet" href="style/layout.css" media="screen" />
</head>
<body onload="draw('picDiv');">
<div id="container">
<div id="header">
<br />
Header info goes here
</div>
<div id="submenu">
</div>
<div id="navmenu">
<ul>
<li /><a href="">Menu items go here</a>
<li /><a href="">Menu items go here</a>
<li /><a href="">Menu items go here</a>
</ul>
</div>
<div id="content">
<a href="javascript:move(-1, 'picDiv');">Prev</a>|<a href="javascript:move(1, 'picDiv');">Next</a>
<div id="picDiv"></div>
</div>
</div>
</body>
</html>
looking to create a gallery using javascript that supports all img formats
below is the code I have so far. would love some help with this. thanks in advance
<html>
<head>
<title>Template</title>
<script>
function picObj(idNum, w, h, altText) {
this.idNum = idNum;
this.width = w;
this.height = h;
this.alt = altText;
}
function picGalleryObj(c, fldr, imgNameFormat, pixArr) {
this.cur_pos = c;
this.folder = fldr;
this.format = imgNameFormat;
this.pix_array = pixArr;
this.move = move;
this.draw = draw;
}
myPix = new Array();
myPix[0] = new picObj('001', 300, 400, image description!!');
myPix[1] = new picObj('002', 300, 400, image description!!');
myPix[2] = new picObj('003', 300, 400, image description!!');
myPix[3] = new picObj('004', 300, 400, image description!!');
myPix[4] = new picObj('005', 300, 400, 'Help Iz!!');
myPix[5] = new picObj('006', 300, 400, image description!!');
myPix[6] = new picObj('007', 300, 400, image description!!');
myPix[7] = new picObj('008', 300, 400, image description!!');
var myGallery = new picGalleryObj(1, 'pix', 'Picture ', myPix);
function move(pos, div_id) {
this.cur_pos += pos;
if(this.cur_pos < 1) {
this.cur_pos = this.pix_array.length;
}
if(this.cur_pos > this.pix_array.length) {
this.cur_pos = 1;
}
draw(div_id);
}
function draw(div_id) {
the_string = "";
the_string += "<img src='" + this.folder + "/" + this.format + " + this.cur_pos + ".jpg' alt='" + this.pix_array[this.cur_pos].alt + "' width='" + this.pix_array[this.cur_pos].width + "' height='" + this.pix_array[this.cur_pos].height + "' />";
document.getElementById(div_id).innerHTML = the_string;
}
</script>
<link rel="stylesheet" href="style/layout.css" media="screen" />
</head>
<body onload="draw('picDiv');">
<div id="container">
<div id="header">
<br />
Header info goes here
</div>
<div id="submenu">
</div>
<div id="navmenu">
<ul>
<li /><a href="">Menu items go here</a>
<li /><a href="">Menu items go here</a>
<li /><a href="">Menu items go here</a>
</ul>
</div>
<div id="content">
<a href="javascript:move(-1, 'picDiv');">Prev</a>|<a href="javascript:move(1, 'picDiv');">Next</a>
<div id="picDiv"></div>
</div>
</div>
</body>
</html>