Hello friends! Can you tell me how to make a photo album:
while pressing one button appears an image, while pressing another, appears other image.
I think it is done in Javascript.
I mean this: enter the site Doganlar | ????? ?????????? ?? DOGANLAR.BIZ, and in main page you will be able to see what i am talking about.
Thanks!
1 reply to this topic
#1
Posted 24 March 2011 - 08:08 AM
|
|
|
#2
Posted 26 March 2011 - 04:17 AM
This does it with plain javascript, assuming the images are in the same directory of the .html file.
This obviously looks ugly as crap, but with JQuery you can propably add a fadeIn of some kind on the imageTag.
And the init() becomes the $(document).ready(function(){ ... });
Edit: to have multiple buttons pointing to their image, you can do something like
<html>
<head>
</head>
<script type="text/javascript">
var imageTag;
var images;
var index;
function init(){
imageTag = document.getElementById("image");
images = new Array();
images[0] = "image1.png";
images[1] = "image2.png";
images[2] = "image3.png";
index = 0;
}
function next(){
if(index == images.length-1){
index = 0;
} else {
index++;
}
imageTag.setAttribute("src", images[index]);
}
</script>
<body onload="init()">
<img id="image" src="image1.png"/>
<input type="button" onclick="next()" value="next"/>
</body>
</html>
This obviously looks ugly as crap, but with JQuery you can propably add a fadeIn of some kind on the imageTag.
And the init() becomes the $(document).ready(function(){ ... });
Edit: to have multiple buttons pointing to their image, you can do something like
....
function next(imageName){
imageTag.setAttribute("src", imageName);
}
....
<input type="button" onclick="next('image1.png')" value="1"/>
<input type="button" onclick="next('image2.png')"" value="2"/>
<input type="button" onclick="next('image3.png')"" value="3"/>
And you can drop everything related to the images and index variables
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









