Thursday, March 12, 2009

Text / Image Slideshow

This is a simple basic example to slideshow the text given in an array. Here we use array to retrieve the text and pass to the slide show.

<html>
<head>
<title>Arrays and Loops</title>
<script type = "text/javascript">

var tips = new Array("Hello welcome.", "welcome to findmysolutions.blogspot.com", "Here you find a simple solutions.","javascript made simple","thanks you");
var index = 0;
function scroll() {
document.tip_form.tip_box.value = tips[index];
index++;
if (index == tips.length)
{
index = 0;
}
setTimeout("scroll()", 3500);
}

</script>
</head>
<body onLoad = "scroll();">
<form name = "tip_form">
<textarea name = "tip_box" rows = "3" cols = "30">
</form>
</body>
</html>

Here the text will be scrolled.

The same thing will be applied for the images the only change we need to do is just change the text value to the image path where the images are stored.

By adding the code <img src='test/testimage1.jpg'> ,<img src='test/testimage2.jpg'>
<img src='test/testimage3.jpg'> and so on. Then the images will be displayed instead of text.

No comments:

Post a Comment