שלום, הבאתי כאן מדריך של תמונות שמתחלפות בלחיצה (אפשר לשנות את קריאת הפעולה לonLoad אז זה כל טעינה של עמוד זה יהיה רנדומלי D: )
קוד PHP:
<SCRIPT LANGUAGE="JavaScript">
<!--
/////////////////////////////////////////////
/////
///// IATRAF.CO.IL
///// KING145
///// ALL RIGHT RESERVEDS!
/////
/////
/////////////////////////////////////////////
function TheRoundNum()
{
var x = Math.floor(Math.random()*8/*The Number Of Arrays*/)
return x;//Return the Random Number
}
function TheRoundImg()
{
var NumArr = TheRoundNum();//The Return X;
var TheImg = new Array(8)//If add or delete Variables change the num and change the num on function TheRoundNum()
TheImg[0] = "<img src='http://www.maniacworld.com/amazing-cars.jpg'>";
TheImg[1] = "<img src='http://www.grouplotus.com/staticfiles/img/app/sections/headers/home_cars.jpg'>";
TheImg[2] = "<img src='http://assets.nydailynews.com/img/2008/03/20/gal_car_stars1.jpg'>";
TheImg[3] = "<img src='http://www.disneyfrontier.com/wp-content/uploads/2006/11/_assets_resources_2006_11_holden_cars_car.jpg'>";
TheImg[4] = "<img src='http://www.automotoportal.com/media/images/vijesti/060711010.jpg'>";
TheImg[5] = "<img src='http://vwkombi.com/photos/volkscars/Images/Cars.jpg'>";
TheImg[6] = "<img src='http://www.exlcars.com/images/car1.jpg'>";
TheImg[7] = "<img src='http://upload.wikimedia.org/wikipedia/commons/2/22/Saab_Aero-X_Concept_Car_(195993839).jpg'>";
document.getElementById("DivImg").innerHTML = TheImg[NumArr];//insert To the div The one of the Variables array. NumArr = return X;
}
//-->
</SCRIPT>
</HEAD>
<BODY onLoad="TheRoundImg()">
<div id="DivImg"></div>
</BODY>
תהנו!
נ.ב. אם אתם משנים את מספר המשתנים במערך אל תשכחו לשנות את המספר גם בפונקצייה הראשונה וגם בשנייה! D: