Jump to content

Slideshow Images


blob84

Recommended Posts

HI, i have a problem i have this script:the slideshow function <cambiaImg> doesn't works, i don't understand why... :)

<html><head><script type="text/javascript"><!-- function insertDivImage (linkImage) {						if(document.getElementById && document.createElement) {										  					createDiv = document.createElement("div");					createDiv.setAttribute("id", "containerSlide");				createDiv.setAttribute("style", "width: 400px;");				createDiv.setAttribute("style", "height: 400px;");				createDiv.setAttribute("style", "position: absolute;");				createDiv.setAttribute("style", "border: 1px solid #000000;"); 										document.getElementById("principal").appendChild(createDiv);			  								pulsante=document.createElement("input");				pulsante.setAttribute("id", "closeSlide");				pulsante.setAttribute("type", "button");				pulsante.setAttribute("value", "chiudi");										document.getElementById("containerSlide").appendChild(pulsante);								pulsante=document.createElement("input");				pulsante.setAttribute("id", "forwSlide");				pulsante.setAttribute("type", "button");				pulsante.setAttribute("value", "avanti");				pulsante.setAttribute("onclick", "cambiaImg(1);");										document.getElementById("containerSlide").appendChild(pulsante);								pulsante=document.createElement("input");				pulsante.setAttribute("id", "backSlide");				pulsante.setAttribute("type", "button");				pulsante.setAttribute("value", "indietro");				pulsante.setAttribute("onclick", "cambiaImg(-1);");										document.getElementById("containerSlide").appendChild(pulsante);								img=document.createElement("img");				img.setAttribute("alt", "slide");						img.setAttribute("src", linkImage);									document.getElementById("containerSlide").appendChild(img);			 						}		}						NewImg = new Array ("http://www.mentelocale.it/img_contenuti/collaboratori/grandi/Citta%20arte%20scienze%20Valencia.jpg", "http://www.edb.utexas.edu/resources/team/images/L1_shack.jpg", "http://img510.imageshack.us/img510/9830/vetrataadesivjl5.gif");			var ImgNum = 0;			var ImgLength = NewImg.length - 1;					function cambiaImg(direzione) {			if (document.images) {				ImgNum = ImgNum + direzione;				if (ImgNum > ImgLength) {					ImgNum = 0;				}								if (ImgNum < 0) {				ImgNum = ImgLength;				}							document.getElementById("containerSlide").src = NewImg[ImgNum];			}		}		//--></script> </head><body id="principal"><br /><input type="button" value="bottone" onclick="insertDivImage('http://www.mentelocale.it/img_contenuti/collaboratori/grandi/Citta%20arte%20scienze%20Valencia.jpg')"; /></body></html>

Link to comment
Share on other sites

the error is document.getElementById("containerSlide").src = NewImg[imgNum];must be the id of the tag img document.getElementById("slideImage0").src = NewImg[imgNum];and I add img.setAttribute("id", "slideImage0);Sometimes i need to take a break :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...