- Apr 15, 2012
- 20
- 0
- 66
So I have some really rough html and Im not checking to see if it looks good I just want it to work. I'm trying to make an gallery by using a series of switch statements and try loops and right now I'm stuck
any help would be nice. Any hate or non helpful comments are not welcomed.
The HTML
The JavaScript
The HTML
Code:
<html>
<head>
<title>New Think Tank Lightbox</title>
<link rel="StyleSheet" href="image_gallery.css" />
<script type="text/javascript" src="image_gallery.js"></script>
</head>
<body>
<div>
<ul>
<li><a href="#" onmousedown="prev();">Prev</a><li>
</ul>
<div>
<div>
<img src="images/bcf.jpg" height="295" width="510" id="panel"/>
</div>
<div>
<img src="images/bcf.jpg" height="60" width="103" onmouseover="getBigger1();" onmouseout="getSmaller1();" onmousedown="display1();" id="img1"/>
<img src="images/bcb.jpg" height="60" width="103" onmouseOver="getBigger2();" onmouseout="getSmaller2();" onmousedown="display2();" id="img2"/>
</div>
</div>
<ul>
<li><a href="#" onmousedown="next();">Next</a></li>
</ul>
</div>
</body>
</html>
Code:
onload="gallery();"
//functions for image 1
function getBigger1() {
document.getElementById("img1").width="155";
document.getElementById("img1").height="100";
}
function getSmaller1() {
document.getElementById("img1").width="103";
document.getElementById("img1").height="60";
}
function display1() {
document.getElementById("panel").src="images/bcf.jpg";
}
//functions for image 2
function getBigger2() {
document.getElementById("img2").width="155";
document.getElementById("img2").height="100";
}
function getSmaller2() {
document.getElementById("img2").width="103";
document.getElementById("img2").height="60";
}
function display2() {
document.getElementById("panel").src="images/bcb.jpg";
}
//variables
var i = 1
function gallery() {
try {
switch(i) {
case 1:
document.getElementById("panel").src="images/bcf.jpg";
break;
case 2:
document.getElementById("panel").src="images/bcb.jpg";
break;
default:
document.getElementById("panel").src="images/bcf.jpg";
}
}catch (err){
alert("Yeah Didn't work!");
}
}
function prev() {
var i = -1;
return true
}
function next() {
var i = +1;
return true
}
Last edited:
